Bug #69448 MySQL ODBC drivers incorrectly quotes TableName when calling SQLPrimaryKeys
Submitted: 12 Jun 2013 10:19 Modified: 16 Jun 2014 5:59
Reporter: Ladislav Karrach Email Updates:
Status: Patch approved Impact on me:
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.2.2 OS:Any
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[12 Jun 2013 10:19] Ladislav Karrach
Consider that, we have table created using quoted table name (with embedded quote):

CREATE TABLE `test``1` (...)

Then when I call SQLPrimaryKeys with TableName=="test`1"
error occurs: [MySQL][ODBC 5.2(a) Driver][mysqld-5.1.45-community]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 '2`' at line 1

It is caused by incorrectly escaped TableName for usage in SHOW KEYS FROM ...
It is escaped like : `test\`1` but should be `test``1`

Look at mysql_list_dbkeys() 

How to repeat:
CREATE TABLE `test``1` (...)

and then use SQLPrimaryKeys with TableName set to "test`1"
[12 Jun 2013 10:37] Bogdan Degtyariov

Thank you very much for reporting a problem in MySQL software.
I was able to repeat the problem.
Setting the status of the report to "Verified".
[19 Jun 2013 13:23] Bogdan Degtyariov
The patch is really simple - just one line.

=== modified file 'driver/utility.c'
--- driver/utility.c	2013-06-19 07:13:50 +0000
+++ driver/utility.c	2013-06-19 06:44:24 +0000
@@ -2491,7 +2491,7 @@
         overflow= TRUE;
-      *to++= '\\';
+      *to++= escape != '`' ? '\\' : '`';
       *to++= escape;
[20 Jun 2013 5:39] Ladislav Karrach
Thanks Bogdan,
can you please estimate when this patch will be included in regular release of ODBC driver?
There is also another pending patch for bug #67793 from January.
[20 Jun 2013 6:37] Bogdan Degtyariov

The company policy does not allow us to make any official promises about including patches or features into any particular version of the software products. I will try to push it into Connector/ODBC 5.2.6, but as I said the destination version can be changed at any moment and therefore under no circumstances you should rely on the assumption I have just made. 

Also, the same policy is very strict about disclosing dates of any software release. Only the official announcement made prior to the release can tell the release date to the public. We cannot allow to make misleading promises as it might impact business of our users and customers. Therefore, the decision of making a promise or announce the date is made on a high level of management and treated very seriously.

About the bug 67793: the patch has been pushed into the revision 1149 of the sources a few days ago. Updating the bug status now.

[23 Oct 2013 9:46] Ladislav Karrach
Can this patch be applied?
[16 Jun 2014 5:59] Ladislav Karrach
It seems, that this fix is already included in 5.3.2, does not?
If yes, then IMO this report can be closed.