Bug #65200 Long table names crash OBDC driver
Submitted: 4 May 2012 10:02 Modified: 24 Jul 2013 14:18
Reporter: Ian Wright Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1 OS:Windows (Windows 7 32 or 64 bit)
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[4 May 2012 10:02] Ian Wright
Description:
Attempting to import tables with a long name causes the driver (and therefore Access/Excel to crash)

Faulting application name: MSACCESS.EXE, version: 14.0.6024.1000, time stamp: 0x4d83e520
Faulting module name: myodbc5.dll, version: 5.1.11.0, time stamp: 0x4f9b1ada
Exception code: 0xc0000409
Fault offset: 0x00000000000053de
Faulting process id: 0x1498
Faulting application start time: 0x01cd29da72257da5
Faulting application path: C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE
Faulting module path: C:\Program Files\MySQL\Connector ODBC 5.1\myodbc5.dll
Report Id: eeb283f1-95cd-11e1-9497-1c659d50dfa8

How to repeat:
Try to import a table with a long table name

Suggested fix:
Workaround is to make the table names shorter
[4 May 2012 13:29] MySQL Verification Team
Please provide a table name example and which version of Access?. Thanks.
[4 May 2012 13:38] Ian Wright
Access version is Professional Plus 2010 with SP1 - details in error log message

This table will crash the import (works up until thisisaverylongtab)
delimiter $$

CREATE TABLE `thisisaverylongtablename` (
  `idthisisaverylongtablename` int(11) NOT NULL,
  `thisisaverylongtablenamecol` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`idthisisaverylongtablename`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
[9 May 2012 13:45] MySQL Verification Team
Linking Table

Attachment: access-crash.png (image/png, text), 97.25 KiB.

[9 May 2012 13:47] MySQL Verification Team
Thank you for the feedback. See prior attached screen-shot.
[10 May 2012 15:52] Eugenio Cattaneo
I am having exactly the same problem, Access crash when I try to connect a Mysql table using the ODBC 5.01.11.00
[17 May 2012 10:48] Bogdan Degtyariov
MySQL ODBC Driver 5.1.11 crashes when calling SQLTables function. To make it crash one has pass a really long database or/and table name to the function, which causes the internal query buffer to overflow.

The solution is simple - extend the buffer from char[255] to char[512].
The maximum length for database and the table are 64 and 64 characters respectfully. So, extending the query buffer to 512 bytes should be sufficient.
Also, the driver has to check the maximum length for the parameters given.
It must not let pass the table name longer than 64 characters. Many catalog functions can be crashed by giving database/table/column names with the length of 1000.
[17 May 2012 17:21] Ben Ernest-Jones
I don't think that's it - the example above (which matches what I'm seeing) causes a crash even with a table name of 20+ characters (I haven't experimented to find the exact length).  I've had to roll back the driver to version 5.1.10 for now, and it works fine for the same tables.
[18 May 2012 3:47] Bogdan Degtyariov
patch v1

Attachment: patch65200.diff (application/octet-stream, text), 5.48 KiB.

[18 May 2012 3:49] Bogdan Degtyariov
That is really the case, I was saying about the theoretical possibility of max 64
characters. However, the Information_Schema queries are really long and they take up to 235-240 characters leaving only 15-20 characters for the table name.
If it is longer the driver crashes.

Please observe the patch uploaded above. It stopped crashing for me when I patched the driver.
[18 May 2012 13:27] Ben Ernest-Jones
Ah, makes sense.  I'll try it out next chance I get, thanks.
[5 Jun 2012 7:29] Tobias Nitsche
I am facing the same problem, but installing the patch seems very hard to me (read a tutorial - looked very difficult!). Can we get a compiled version of this fix, so that we can simply replace the dll-file? Need this fix very fast! Thanks for your help!
[5 Jun 2012 11:14] Lawrenty Novitsky
I would multiply NAME_CHAR_LEN by 4 to cover the edge case when all characters in names are escaped.
[5 Jun 2012 20:59] Stephen Lloyd
Similar problem.  Able to connect with MS Access 2010 to MySQL server via the 5.1.11 myodbc.dll.  However, the tables with file names of 19 characters or greater cause the crash.

Per the mention of adjusting the internal query buffer, how/where is this setting changed?  Or if 5.1.10 does not have this problem how can I obtain this dll?

Thanks!!
[6 Jun 2012 8:30] Bogdan Degtyariov
fixed driver source file

Attachment: catalog.c (text/plain), 44.66 KiB.

[6 Jun 2012 8:43] Bogdan Degtyariov
Unfortunately, we cannot distribute the non-official intermediate builds.
However, I uploaded the source file (catalog.c), which has the patch applied.

You can download the source distribution from 
http://www.mysql.com/downloads/connector/odbc/5.1.html

Then unpack it (WinRar or similar archive program can unpack .tar.gz) and 
replace driver/catalog.c.
Then build the driver dll from sources using cmake and Visual C++ Express,
which is free.

The instructions on building ODBC driver can be found here:
http://dev.mysql.com/doc/refman/5.5/en/connector-odbc-installation-source-windows.html#con...
[12 Jun 2012 17:42] David Erdreich
Is there any visibility as to when this will be incorporated into the next version of the driver (and when that release will take place)?
[13 Jun 2012 17:02] Ethics Commission
I am having this same issue. Which buffer needs to be increased to prevent this isse? There are several in mysql.ini.
[22 Jun 2012 10:27] Bogdan Degtyariov
David:

This will be incorporated into the version 5.1.12, but the exact date of the release cannot be disclosed prior to the official announcement, sorry...

Ethics Commission:

As about my.ini, it controls the server buffers that have nothing to do with ODBC problem described here.
[22 Jun 2012 17:53] Ethics Commission
Thank you. I realized that right after I posted. Downgrading to the 5.1.10 driver works great in the meantime.
[22 Jun 2012 21:08] todd furubayashi
Hi,  

having the same issue.  I uninstalled 5.1.11 and trying to install version 5.1.10 but it won't let me because it thinks i still have 5.1.11 and won't let me install an older version.

how do I fully uninstall 5.1.11?  5.1.10 is no longer in my directory.
[22 Jun 2012 21:56] todd furubayashi
got it to fully uninstall.  thank you to all for the comments.  this will save me a ton of work.
[27 Jun 2012 7:30] Tomas Telensky
I don't get it:

pecbm_cmp_taxons (16 chars) - Access crashes
ProjStrnadObsItems (18 chars) - OK!
ProjStrnadRecordings (20 chars) - crashes

Seems that with underscore even shorter table names result in crash???
[27 Jun 2012 7:55] Bogdan Degtyariov
The crash happens because of the query buffer overflow.
This buffer contains query text, database and table names.
Hence, with long database name you can get crash on 10 or less characters for the table name.
[18 Jul 2012 6:19] Francesco Adamo
The problem arise also for me on a Windows 7 x64 PC with Access 2010 from the Professional Plus Office Suite and ODBC/Connector v5.1.11.

However I am unable to find ODBC/Connector v5.1.10 for download on the mysql site (the first past version available in archive for download is 5.1.8); can anyone suggest me where can I find the windows installer for v5.1.10.

Thank you in advance!
[22 Jul 2012 16:59] Imad Kheir
Hello Francesco Adamo
Send me your Email, i'll send you the 5.1.10 version of odbc connector
[1 Aug 2012 15:23] John Patterson
I too need a copy of the 5.1.10 driver.
Where can this be acquired?
[4 Aug 2012 8:39] Joan Vallve
@ John Patternson:

Try it here. It worked for me:

http://dev.mysql.com/get/Downloads/Connector-ODBC/5.1/mysql-connector-odbc-5.1.10-win32.ms...
[9 Aug 2012 14:45] Tomas Telensky
Older versions can be found for example here:
http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-ODBC/5.1/
[9 Aug 2012 14:45] Tomas Telensky
Older versions can be found for example here:
http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-ODBC/5.1/
[30 Aug 2012 15:17] Mario Enrique Zapata
Sorry, the sameproblem, i ask if there is not a most simple solution, is quite complicated to change and build again the driver not to mention the time required to do so. besides this problem or bug arise when the system was working properly, what upgrade trigger this bug.
When the binary distribution (.msi file)  will be fixed.

(w7 ultimate 64 bit - ms access 64 bit 2010, ODBC mysql 5.1.11)

thanks, best regards
[16 Sep 2012 17:51] Eric Rohloff
I was finally able to get Mysql imported into Excel 2010 on my windows 7 64 bit machine by going back to ODCB version: mysql-connector-odbc-3.51.30-winx64.msi. I tried the shorter table names but the query would crash when I clicked finish. It always connected fine and I was able to set parameters.
[17 Sep 2012 9:31] Bogdan Degtyariov
You can use Connector/ODBC 5.2.1.
It is beta version, but NO_SSPS=1 option turns it into 5.1 and all new functions will be disabled.
[27 Sep 2012 10:58] Lawrenty Novitsky
5.2.2 is out and it is GA. Naturally it includes the patch for this bug.
[24 Jul 2013 14:18] Daniel So
Added to changelog for 5.1.12:

Calling the SQLTables function with a very long database or table
name could cause a serious error. This fix allows the SQLTables
function to accept database and table names with the maximum length
of 64 characters.