Bug #72737 utf16le charset leads to "The given key was not present in the dictionary"

Submitted: 24 May 2014 8:09 Modified: 10 Aug 2022 17:21
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.8.3 OS:Any
Assigned to: Assigned Account CPU Architecture:Any

[24 May 2014 8:09] Shane Bester
Description:
mysql Information: 3 : 1: Query Opened: select _utf16le "aaaaaaaa"
mysql Information: 4 : 1: Resultset Opened: field(s) = 1, affected rows = -1, inserted id = -1
mysql Information: 4 : 1: Resultset Opened: field(s) = 131072, affected rows = -1, inserted id = -1
The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MySql.Data.MySqlClient.MySqlField.SetFieldEncoding()
   at MySql.Data.MySqlClient.NativeDriver.GetColumnData(MySqlField field)
   at MySql.Data.MySqlClient.NativeDriver.GetColumnsData(MySqlField[] columns)
   at MySql.Data.MySqlClient.Driver.GetColumns(Int32 count)
   at MySql.Data.MySqlClient.ResultSet.LoadColumns(Int32 numCols)
   at MySql.Data.MySqlClient.ResultSet..ctor(Driver d, Int32 statementId, Int32 numCols)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.TracingDriver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlDataReader.Close()
   at MySql.Data.MySqlClient.MySqlCommand.ResetReader()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()

My server:
mysql> show charset like 'utf16le';
+---------+------------------+--------------------+--------+
| Charset | Description      | Default collation  | Maxlen |
+---------+------------------+--------------------+--------+
| utf16le | UTF-16LE Unicode | utf16le_general_ci |      4 |
+---------+------------------+--------------------+--------+
1 row in set (0.00 sec)

mysql> show collation like 'utf16le%';
+--------------------+---------+----+---------+----------+---------+
| Collation          | Charset | Id | Default | Compiled | Sortlen |
+--------------------+---------+----+---------+----------+---------+
| utf16le_general_ci | utf16le | 56 | Yes     | Yes      |       1 |
| utf16le_bin        | utf16le | 62 |         | Yes      |       1 |
+--------------------+---------+----+---------+----------+---------+
2 rows in set (0.00 sec)

How to repeat:
via c/net, run this query against a mysql server that supports the charset:

select _utf16le "aaaaaaaa"

Suggested fix:
add the mapping to function: private static void LoadCharsetMap() ?
don't hardcode charsets?
[24 May 2014 8:09] Shane Bester
same for gb18030 charset
[24 May 2014 8:11] Shane Bester
and geostd8 charset, etc etc
[10 Aug 2022 17:21] Daniel Valdez
This bug has been fixed since Connector/Net 6.7.7 release.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.