| Bug #69169 | Connector/NET cannot read data from a MySql table using UTF-16/UTF-32 | ||
|---|---|---|---|
| Submitted: | 7 May 2013 22:00 | Modified: | 5 Sep 2013 21:23 |
| Reporter: | Fernando Gonzalez.Sanchez | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | 6.6.5 | OS: | Any |
| Assigned to: | Fernando Gonzalez.Sanchez | CPU Architecture: | Any |
| Tags: | Cnet, utf16 | ||
[7 May 2013 22:06]
Fernando Gonzalez.Sanchez
This issue was originally reported in forums at http://forums.mysql.com/read.php?38,585570,585570#msg-585570.
[5 Sep 2013 21:23]
Daniel So
Added the following changelog entry for Connector/NET 6.5.7, 6.6.6, and 6.7.4: "Connector/NET threw a fatal error when trying to read a MySQL table that used the UTF-16 or UTF-32 character set. Mappings for UTF-16 and UTF-32 encodings have now been added."

Description: When trying to read a MySql table that is using character set utf16, Connector/NET throws an error: Fatal error encountered attempting to read the resultset. How to repeat: Using sakila for example, 1. Create a test database: create database test; 2. use test; 3. Create a table based on the actor table: create table actor2 select * from sakila.actor 4. Change the encoding char set: ALTER TABLE actor2 CONVERT TO CHARACTER SET UTF16; /* or UTF32 for that matter */ Now write a .NET app that attempts to read that table: MySqlConnection con = new MySqlConnection(/* fill connection data here */); MySqlCommand cmd = new MySqlCommand("select * from actor2", con); con.Open(); try { using (MySqlDataReader r = cmd.ExecuteReader()) { while (r.Read()) { for (int i = 0; i < r.FieldCount; i++) { System.Console.Write(r.GetValue(i)); System.Console.Write('|'); } System.Console.WriteLine(""); } } } finally { con.Close(); } When ran the error will appear. Suggested fix: On the internal class MySql.Data.MySqlClient.CharSetMap, method LoadCharsetMap add this line: mapping.Add("utf16", new CharacterSet("utf-16BE", 2)); (MySql uses big endian for UTF16). But the way, adding mapping.Add("utf32", new CharacterSet("utf-32BE", 2)); should also be included, since UTF32 fails too. So far workaround is to use UTF8mb3 or UTF8mb4.