Bug #112690 SQLStatistics reports invalid data
Submitted: 11 Oct 2023 11:33 Modified: 16 Jun 11:47
Reporter: Yves Colombani Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:8.1.0 OS:CentOS (7)
Assigned to: CPU Architecture:x86

[11 Oct 2023 11:33] Yves Colombani
Description:
When using SQLStatistics to retrieve the index of a table I am getting the index name in column 6 (as expected) but the type is 0 in column 7 (instead of the index type that must be <>0). The same program executed with version 8.0.33 (and older) of the driver I am getting a type 3 in the column 7.

How to repeat:
Have a table with an index and call SQLStatistics on this table.
In the result set there must be at least 1 row with the index name in column 6 and a numerical value >0 in column 7 (I am getting 0 with the version 8.1.0 of the driver).
[11 Oct 2023 12:53] Yves Colombani
Example program showing the issue

Attachment: csqlbug3.c (text/x-csrc), 2.38 KiB.

[10 Jun 2024 13:11] MySQL Verification Team
Hello Yves Colombani,

Thank you for the bug report.
Please upgrade to latest version and report us back if issue persist even in latest version along with test case. Thank you.

Regards,
Ashwini Patil
[10 Jun 2024 13:44] Yves Colombani
Hello,
Just tried my test example with driver 8.4.0 using prebuilt binaries for Linux x86: the program crashes when executing MySQLStatistics (on an 'strlen'). I am copying below Valgrind output.
YC.

==18294== Memcheck, a memory error detector
==18294== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18294== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==18294== Command: ./csqlbug3
==18294== 
DriverConnect: DSN=Build-test
==18294== Invalid read of size 1
==18294==    at 0x4B09688: ____strtol_l_internal (strtol_l.c:292)
==18294==    by 0x515A864: statistics_no_i_s(void*, unsigned char*, short, unsigned char*, short, unsigned char*, short, unsigned short, unsigned short) (catalog_no_i_s.cc:981)
==18294==    by 0x514959D: statistics_i_s(void*, unsigned char*, short, unsigned char*, short, unsigned char*, short, unsigned short, unsigned short) (catalog.cc:1090)
==18294==    by 0x5149745: MySQLStatistics(void*, unsigned char*, short, unsigned char*, short, unsigned char*, short, unsigned short, unsigned short) (catalog.cc:1122)
==18294==    by 0x518D39E: SQLStatistics (ansi.cc:806)
==18294==    by 0x4871B6A: SQLStatistics (in /usr/local/lib/libodbc.so.2.0.0)
==18294==    by 0x1095BF: main (csqlbug3.c:64)
==18294==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==18294== 
==18294== 
==18294== Process terminating with default action of signal 11 (SIGSEGV)
[16 Jun 11:08] Yves Colombani
The test appears to work with connector 9.3.0 on a Mac/arm64.
[16 Jun 11:47] MySQL Verification Team
Hello Yves Colombani,

Thank you for confirming that it is working with Connector/ODBC 9.3.
Closing the report for now.

Regards,
Ashwini Patil