Bug #107766 8.0.29 ANSI ODBC Driver: SQLColumns returns SQL_WVARCHAR instead of SQL_VARCHAR
Submitted: 5 Jul 2022 18:52 Modified: 3 Aug 2022 16:07
Reporter: Pierre le Riche Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:8.0.29 OS:Windows
Assigned to: CPU Architecture:Any
Tags: ODBC ANSI

[5 Jul 2022 18:52] Pierre le Riche
Description:
Since version 8.0.28 of the ANSI ODBC driver, a call to SQLColumns returns SQL_WVARCHAR in the DATA_TYPE column instead of SQL_VARCHAR for varchar(x) fields. (This is with a utf8mb4 encoding.)

As a result the column data type reported by SQLColumns is inconsistent with the actual data type returned when a SQL query is opened against the same table.

How to repeat:
1) Connect to a database using the ANSI ODBC driver
2) Call SQLColumns and inspect the reported field type for a varchar (utf8mb4 encoding) field
Expected value in the DATA_TYPE column: 12 (SQL_VARCHAR)
Actual value in the DATA_TYPE column: -9 (SQL_WVARCHAR)

Suggested fix:
Please revert the behaviour to what it was in 8.0.27
[6 Jul 2022 7:24] MySQL Verification Team
Hello Pierre le Riche,

Thank you for the report and feedback.

regards,
Umesh
[28 Jul 2022 9:18] Bogdan Degtyariov
Posted by developer:
 
The bug affected not only SQL_VARCHAR, but SQL_CHAR and SQL_LONGVARCHAR as well.

The column types returned by SQLColumns() are mapped as follows:

 - For CHAR SQL type: ANSI Driver returns SQL_CHAR, UNICODE Driver returns SQL_WCHAR
 - For VARCHAR SQL type: ANSI Driver returns SQL_VARCHAR, UNICODE Driver returns SQL_WVARCHAR
 - For LONGVARCHAR SQL type: ANSI Driver returns SQL_LONGVARCHAR, UNICODE Driver returns SQL_WLONGVARCHAR
[28 Jul 2022 12:06] Bogdan Degtyariov
Posted by developer:
 
The patch is pushed into release/8.0.31 source tree.
[3 Aug 2022 16:07] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/ODBC 8.0.31 release, and here's the proposed changelog entry from the documentation team:

With the ANSI ODBC driver, a call to SQLColumns returned the Unicode
DATA_TYPE equivalent; SQL_WVARCHAR instead of SQL_VARCHAR, SQL_WCHAR
instead of SQL_CHAR, and SQL_WLONGVARCHAR instead of SQL_LONGVARCHAR.

Thank you for the bug report.