Bug #106363 SQLColumns call crashes if NO_I_S=1 is not set
Submitted: 3 Feb 3:26 Modified: 2 Jun 4:35
Reporter: Kari Heinola Email Updates:
Status: Analyzing Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:8.0.28 OS:Windows (10)
Assigned to: MySQL Verification Team CPU Architecture:x86 (64-bit)
Tags: NO_I_S, SQLColumns

[3 Feb 3:26] Kari Heinola
Description:
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 8:12] MySQL Verification Team
Hello,

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? 

Regards,
Ashwini Patil
[1 Jun 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)