Bug #67428 ODBC 5.2.2 connector broken for all sql servers older than 5.5.3
Submitted: 30 Oct 2012 22:41 Modified: 19 Jul 2013 15:54
Reporter: Malcolm MacLeod Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:5.2.2 OS:Any
Assigned to: CPU Architecture:Any

[30 Oct 2012 22:41] Malcolm MacLeod
Description:
When working with MySQL servers older than 5.5.3:
myODBC unicode (w) driver fails all statements with error message "Server does not support 4-byte encoded UTF8 characters." even if dealing only with single utf8 byte (ascii only) strings.
myODBC ansi (a) driver works as expected.

When working with MySQL servers newer than 5.5.3:
Both drivers perform as expected.

The older 5.1 series of drivers seem to be crashy/broken in other ways so this leaves no functional way to connect via ODBC to a MySQL server older than 5.5.3
As not all clients can simply upgrade this is of course a pretty huge issue for companies like us who will be unable to provide a solution to our clients until a new fixed version is released...

How to repeat:
1) Set up ODBC (w) driver to connect to an older MySQL server (5.5.2 or lower)
2) Connect to ODBC driver with any software that performs an insert or other such query.
3) Observe failure.

Suggested fix:
sqlwchar_as_utf8_ext has the following incorrect code in it (twice):
if (utf8len)
{
    *utf8mb4_used= 1;
}

It is obvious that this should instead read:
if (utf8len>=4)
{
    *utf8mb4_used= 1;
}

I have built a version of the driver with the above changes and it appears to now function correctly.
[31 Oct 2012 12:05] MySQL Verification Team
Error message

Attachment: odbc-bug67428.png (image/png, text), 28.93 KiB.

[31 Oct 2012 12:06] MySQL Verification Team
Thank you for the bug report. Verified as described.
[31 Oct 2012 12:16] MySQL Verification Team
http://bugs.mysql.com/bug.php?id=67415 marked as duplicate of this one.
[28 May 2013 3:53] SDf Vdfv
The problem still exists in version 5.2.5

Connecting to a 5.1 database gives that error for any string. Even if utf8 (3byte) is selected in the connector.

really wished that compiled fix had gotten uploaded to this report.
[19 Jul 2013 15:54] Daniel So
Added an entry to the Connector/ODBC 5.2.6 changelog:

When using the Unicode-enabled version of the Connector/ODBC driver to connect to any MySQL server of version 5.5.2 or older, all statements failed with with the error message “Server does not support 4-byte encoded UTF8 characters.”