Bug #106363 SQLColumns call crashes if NO_I_S=1 is not set
Submitted: 3 Feb 2022 3:26 Modified: 17 Oct 2022 17:53
Reporter: Kari Heinola Email Updates:
Status: Won't fix Impact on me:
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:8.0.28 OS:Windows (10)
Assigned to: CPU Architecture:x86 (64-bit)
Tags: NO_I_S, SQLColumns

[3 Feb 2022 3:26] Kari Heinola
My code getting all column names with a call to SQLColumns crashes if the driver setting 'Don't use INFORMATION_SCHEMA for metadata' or NO_I_S=1 is not set. My code worked with 8.0.26, I have not tested with 8.0.27.

I tested with another computer running Windows 7 and another program (Franz Allegro Lisp with AODBC) with the same results.

How to repeat:
My code does not do anything special. Connection string is like
  "DRIVER=MySQL ODBC 8.0 Unicode Driver;Database=dpp_test_db;CharSet=utf8"

The last line in the odbc trace file sql.log shows

rdblink         8bb0-64e0	ENTER SQLColumnsW 
		HSTMT               0x000001F30357BEB0
		WCHAR *             0x0000000000000000 <null pointer>
		SWORD                        0 
		WCHAR *             0x0000000000000000 <null pointer>
		SWORD                        0 
		WCHAR *             0x000001F304DD1F00 [      -3] "test_table\ 0"
		SWORD                       -3 
		WCHAR *             0x0000000000000000 <null pointer>
		SWORD                        0
[20 May 2022 8:12] MySQL Verification Team

Thank you for the bug report.
Could you please provide repeatable test case(please make it as private if you prefer) to reproduce this issue at our end? 

Ashwini Patil
[1 Jun 2022 19:41] Kari Heinola
Creating a test case would take a lot of time as this is not a standalone program.

I tested this again and the issue is still in the latest 8.0.29 driver and I get the following exception and backtrace in VS 2022:

  Unhandled exception at 0x00007FFF697E4FD9 in rdblink.exe: Microsoft C++ exception: std::out_of_range at memory location 0x000000B29855DAC0.

 msvcp140.dll!std::_Xout_of_range(const char * _Message) Line 25
	at D:\a\_work\1\s\src\vctools\crt\github\stl\src\xthrow.cpp(25)
[Inline Frame] myodbc8w.dll!std::map<std::string,int,std::less<std::string>,std::allocator<std::pair<std::string const ,int>>>::at(const std::string &) Line 331
	at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\map(331)
myodbc8w.dll!get_sql_data_type_from_str(const char * mysql_type_name) Line 1134
	at C:\build\sb_1-6514100-1648115000.76\mysql-connector-odbc-8.0.29-src\driver\utility.cc(1134)
myodbc8w.dll!columns_i_s(void * hstmt, unsigned char * catalog, unsigned long catalog_len, unsigned char * schema, unsigned long schema_len, unsigned char * table, unsigned long table_len, unsigned char * column, unsigned long column_len) Line 911
	at C:\build\sb_1-6514100-1648115000.76\mysql-connector-odbc-8.0.29-src\driver\catalog.cc(911)
myodbc8w.dll!MySQLColumns(void * hstmt, unsigned char * catalog_name, short catalog_len, unsigned char * schema_name, short schema_len, unsigned char * table_name, short table_len, unsigned char * column_name, short column_len) Line 1042
	at C:\build\sb_1-6514100-1648115000.76\mysql-connector-odbc-8.0.29-src\driver\catalog.cc(1042)
myodbc8w.dll!SQLColumnsW(void * hstmt, wchar_t * catalog, short catalog_len, wchar_t * schema, short schema_len, wchar_t * table, short table_len, wchar_t * column, short column_len) Line 220
	at C:\build\sb_1-6514100-1648115000.76\mysql-connector-odbc-8.0.29-src\driver\unicode.cc(220)
[26 Aug 2022 11:10] MySQL Verification Team

Thank you for the feedback.
Could you please provide table structure for 'test_table'?

Ashwini Patil
[26 Aug 2022 19:19] Kari Heinola
table structure for 'test_table'

Attachment: dpp_test_db_test_table.sql (application/octet-stream, text), 3.99 KiB.

[26 Sep 2022 21:22] Ben Lewis

I have also encountered this bug. I have managed to reproduce this bug using the following python script:

import pyodbc
connection = pyodbc.connect("DSN=MySQL;unicode_results=True;UID=Admin;PWD=")

with connection.cursor() as cursor:
    cursor.execute("DROP DATABASE IF EXISTS bug")
    cursor.execute("CREATE DATABASE bug")
    cursor.execute("USE bug")
    cursor.execute("CREATE TABLE points (point POINT)")

This crashes on the last line. This appears to only be a problem if a specific spatial geometry type is used, i.e. if I replace POINT with GEOMETRY, it doesn't crash. 

I was using version 8.0.30 of the ODBC driver.
[13 Oct 2022 1:18] Kari Heinola
Seems that in 8.0.31 parameter NO_I_S is removed.  As I do not know any way to get things to work with 8.0.31, for now, I need to revert to an older ODBC driver version.
[17 Oct 2022 12:43] MySQL Verification Team
Hello Kari Heinola,

Thank you for the details.
Closing the report as "won't fix" since NO_I_S is no longer supported from 8.0.31. For more info please see here https://dev.mysql.com/doc/relnotes/connector-odbc/en/news-8-0-31.html 

Ashwini Patil
[17 Oct 2022 17:53] Kari Heinola
The driver is still crashing, and you are closing the bug as "won't fix" since the only way I get SQLColumns call to work (using NO_I_S) is removed?