Bug #88950 ResultSet.cs: incorrect assignment to the _fieldHashCs field.
Submitted: 17 Dec 2017 22:08 Modified: 29 Jun 2018 20:43
Reporter: Philip Bridson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.10.5 / 8.0.9 OS:Any
Assigned to: CPU Architecture:Any

[17 Dec 2017 22:08] Philip Bridson
Description:
The _fieldHashCs is meant to implement a case-sensitive lookup of a fields ordinal; however it is initialized using a case-insensitive comparer on line 291 of ResultSet.cs.

The current line in the LoadColumns method is:

_fieldHashCs = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

which is identical to the Case-Insensitive comparison on the following line:

_fieldHashCi = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

How to repeat:
This is a code error. You can find the issue on line 291 of ResultSet.cs

Suggested fix:
I believe the initializer for _fieldHashCs should be as follows:

_fieldHashCs = new Dictionary<string, int>(StringComparer.Ordinal);

If the intention was to only ever perform a case-insensitive comparison, then the _fieldHashCs field should be removed completely from code to improve performance.
[17 Dec 2017 22:12] Philip Bridson
The bug is also in version 8.0.9.
[19 Dec 2017 4:24] Bradley Grainger
This bug appears to have been introduced here: https://github.com/mysql/mysql-connector-net/commit/c1456423973beb3a58636fe665dbd36102809a...
[19 Dec 2017 6:31] Chiranjeevi Battula
Hello Philip Bridson,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[29 Jun 2018 20:43] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 6.10.8 release, and here's the changelog entry:

The case-sensitive lookup of field ordinals was initialized using
case-insensitive comparison logic. This fix removes the original
case-sensitive lookup.

Thank you for the bug report.