Bug #80887 mysqldbcompare does not escape column names
Submitted: 29 Mar 2016 14:55 Modified: 30 Mar 2016 9:22
Reporter: Mike Lewis Email Updates:
Status: Can't repeat Impact on me:
Category:MySQL Utilities Severity:S2 (Serious)
Version:1.5.6 OS:Ubuntu (12.04)
Assigned to: CPU Architecture:Any

[29 Mar 2016 14:55] Mike Lewis
Using columns that have special characters in them (in this case, specifically spaces), mysqldbcompare will not escape those columns, and will return an error with text like:

Query failed. 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Column 1 = '21' AND Column 2 = '4' AND Column 3 = '1' AND Column 4' at line 1

where the columns are supposed to be entitled `Column 1`, `Column 2`, and so on.

I have no more information on the issue than that, since that is all mysqldbcompare returns. It happens every time I have a multi-column primary key where any of the columns have spaces in them, but is likely not limited to that scenario, as I haven't done a lot of testing.

How to repeat:
Create a table with four columns, the first three being part of the primary key. Name them `Column 1`, `Column 2`, `Column 3`, and `Column 4`. Repeat this step with another database, and fill both with the same data.

Change the value of `Column 4` in one database, and run mysqldbcompare (using the --run-all-tests options if the databases are named differently).

Suggested fix:
Use backticks on every table name, as it will prevent errors like this from popping up.
[29 Mar 2016 14:57] Mike Lewis
Also, I can confirm that this also occurs on a computer running OS X 10.11.3, running the identical version of MySQL as the Ubuntu machine listed in the bug description (5.6.29)
[30 Mar 2016 9:22] Umesh Shastry
Hi Mike,

Thank you for the report.
I could not repeat the issue with the provided description.
Could you please provide exact schema/subset of data and unaltered mysqldbcompare command to repeat this issue at our end? You may want to mark the note as private post uploading here if required.

If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.