Bug #121583 Connector/NET GetOrdinal does not prefer exact-case column matches
Submitted: 22 Oct 16:09
Reporter: Alaric Dailey Email Updates:
Status: Open Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:Connector/NET 8.4.0, 9.7.0, and 26.10.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: ado-net, conformance, Connector-NET

[22 Oct 16:09] Alaric Dailey
Description:
The ADO.NET IDataRecord.GetOrdinal contract requires name lookup to return the ordinal of the named field. When a result set contains column names that differ only by case, Connector/NET should prefer the exact-case match before applying case-insensitive fallback. The current implementation uses only case-insensitive lookup, so the returned ordinal can identify the wrong column. This was found by pengdows.AdoNetApiTest.conformance.

How to repeat:
1. Run a SELECT that returns two columns whose names differ only by case, for example aliases ColumnName and columnname.
2. Execute the command with MySql.Data and obtain the reader.
3. Call reader.GetOrdinal("ColumnName") and reader.GetOrdinal("columnname").
4. Observe that exact-case lookup is not preferred and can return the same/wrong ordinal instead of the exact matching column.

The conformance regression test is DataReader.GetOrdinal_prefers_the_exact_case_match in pengdows.AdoNetApiTest.conformance.

Suggested fix:
Maintain a case-sensitive name-to-ordinal lookup for exact matches, then use the existing case-insensitive lookup only as fallback. Regression tests should cover exact and case-insensitive lookup.