Bug #44504 Connector/ODBC gives error with custom UCA collation
Submitted: 27 Apr 2009 23:11 Modified: 13 May 2011 22:57
Reporter: Miguel K Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.1.8 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any

[27 Apr 2009 23:11] Miguel K
Description:
Error given is:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

On my production server, the number of open connections then goes to the maximum and the server returns the "too many connections" message.

MySQL 5.1.24
Connector/ODBC 5.1.5
ASP.NET 3.5 on Windows Server 2008

Cheers

How to repeat:
Add after <charset name="utf8"> to Index.xml:

<collation name="utf8_dquote_ci" id="252">
<rules>
<reset>\u0000</reset>
<s>\u0022</s> <!-- double quote -->
</rules>
</collation>

CREATE TABLE  test2 (
  `col1` varchar(100) NOT NULL,
  PRIMARY KEY  (`col1`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO test2 (col1) VALUES('one');

-- run ASP.NET webpages (attached files) (One with ODBC connector, the other using .NET connector).
-- Both show "one".  They are both working.

-- change to the custom character set
ALTER TABLE `test2` MODIFY COLUMN `col1` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_dquote_ci NOT NULL;

-- Connector/Net page works fine
-- Connector/ODBC page now gives error:
-- ASP.NET error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
[4 May 2009 14:09] Susanne Ebrecht
Many thanks for writing a bug report. This looks more like a MyODBC problem then a charset problem.

Set category to MyODBC.
[4 May 2009 14:18] Tonci Grgin
Hi Miguel. I see no point in both attached asp pages as connection string is not visible there. Can you show exact connection strings used please.
[4 May 2009 16:53] Miguel K
Here you go:
DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=diction9;USER=xxxx;PASSWORD=xxxxx;charset=utf8;OPTION=3
[13 May 2011 22:57] Miguel K
Wow, two years.

I can confirm that this still does not work with
MySQL 5.5.10
Connector/ODBC 5.1.8

Though the error message has changed to:
ERROR [07006] [MySQL][ODBC 5.1 Driver][mysqld-5.5.10]Source character set not supported by client

The source character set is utf8, which is definitely supported by Windows.  The problem seems to be that Windows is rejecting a collation that it doesn't recognize.  I have no idea why Windows would care what the collation is as long as it knows that the data is UTF-8.

I hope a fix can be found soon.

Here is a work-around:
This works:
SELECT col1 collate utf8_unicode_ci AS col1 FROM test2
While this still does not:
SELECT col1 AS col1 FROM test2
[22 May 2018 20:16] Mor Sagmon
Same error for me, with ODBC 5.3.

Miguel's workaround did not fix it for me.
I have charset=utf8 and collation=utf8_general_ci (or utf8_unicode_ci gives the same error).