Bug #54212 3.51 Driver returns wrong results about column sensitivity
Submitted: 3 Jun 2010 17:24 Modified: 18 Jun 2010 15:03
Reporter: Lawrenty Novitsky Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:3.51 OS:Any
Assigned to: Lawrenty Novitsky CPU Architecture:Any

[3 Jun 2010 17:24] Lawrenty Novitsky
SQLColAttribute(...SQL_DESC_CASE_SENSITIVE...) returns SQL_FALSE for binary types and SQL_TRUE for the rest. Should be the other way around.

"SQL_TRUE if the column is treated as case-sensitive for collations and comparisons.
SQL_FALSE if the column is not treated as case-sensitive for collations and comparisons or is noncharacter."

            *(SQLINTEGER *)NumericAttributePtr= (field->flags & BINARY_FLAG ?
                                                 SQL_FALSE : SQL_TRUE);

How to repeat:
the bug is pretty obvious from the code snippet

Suggested fix:
Make it in sync with 5.1 code

 if (field->flags & BINARY_FLAG) /* TODO this doesn't cut it anymore */
      irrec->case_sensitive= SQL_TRUE;
      irrec->case_sensitive= SQL_FALSE;

Although the comment says that is not all what is needed there, it's definitely better than current code.
[3 Jun 2010 18:21] Jim Winstead
The described patch sounds fine. Consider it pre-approved by me.
[3 Jun 2010 18:27] Jim Winstead
The get_sql_data_type() function has what may be a better test for the binary-ness of a field.
[3 Jun 2010 22:47] Lawrenty Novitsky
the patch

Attachment: bug54212.diff (application/octet-stream, text), 3.47 KiB.

[3 Jun 2010 23:31] Lawrenty Novitsky
Jim, I have to ask you to re-review the patch since it's slightly different from what we discussed.
The difference is that c2(41th) field from the testcase wasn't recognized as binary by the "binary-ness test" from get_sql_data_type(). So i've slightly changed it.
[4 Jun 2010 13:11] Lawrenty Novitsky
pushed as rev#714. Probable destination is 3.51.28
I assume this approval as a blessing to apply similar change in other places of 3.51 and 5.1(about detecting binary field). but will probably do some more research on that.
[18 Jun 2010 15:03] Tony Bedford
An entry has been added to the 3.51.28 changelog:

SQLColAttribute(...SQL_DESC_CASE_SENSITIVE...) returned SQL_FALSE for binary types and SQL_TRUE for the rest. It should have returned SQL_TRUE for binary types, and SQL_FALSE for the rest.