Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.2.10
-
None
Description
In 3.2.10, SQLGetTypeInfo(SQL_ALL_TYPES) returns TYPE_NAME values whose length indicator counts the terminating NUL. For example, "BIT" is reported as 4 bytes and the buffer contains 42 49 54 00. It happens on all 43 rows, whether the column is bound as SQL_C_CHAR or as SQL_C_WCHAR (8 bytes for "BIT"). 3.1.20 reports 3 bytes against the same server, so this is a regression.
Per the ODBC specification the length indicator must not include the null-termination character. Clients that compare type names as strings, for example when mapping TYPE_NAME to their own types, no longer get matches. A .NET client reading GetSchema("DataTypes") through System.Data.Odbc sees names like "INTEGER\0", and in our case this makes type lookups fail.
How observed
Connect with SQLDriverConnect, call SQLGetTypeInfo(hstmt, SQL_ALL_TYPES), then SQLBindCol(hstmt, 1, SQL_C_CHAR, buf, sizeof(buf), &ind) (or SQL_C_WCHAR) for the TYPE_NAME column and SQLFetch each row. ind equals the string length plus 1, and the last byte of buf within ind is 0. For "BIT" that gives ind = 4 and 42 49 54 00.
Environment
Windows 11, 64-bit driver, odbc32 driver manager, MariaDB server 12.1.2. Connector/ODBC 3.2.10 is affected and 3.1.20 is not.
I can attach a small C reproducer if useful.