Bug #105141 ODBC Driver incorrectly report SQL_SCHEMA_TERM
Submitted: 5 Oct 2021 18:32 Modified: 22 Feb 8:45
Reporter: Farid Zidan (Candidate Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:8.0.26 OS:Windows
Assigned to: CPU Architecture:x86

[5 Oct 2021 18:32] Farid Zidan
Description:
Driver reports that MySQL server supports both catalog (correct) and schema (incorrect).

    rc = SQLGetInfo(
		m_hdbc, 
		SQL_SCHEMA_TERM,
        m_szSchemaTerm, 
		sizeof(m_szSchemaTerm),
		&cb);

returns "database" as the scheam term. Should return empty string.

Driver also incorrectly reports schema usage as 31:

        rc = SQLGetInfo(
			m_hdbc, 
			SQL_SCHEMA_USAGE, 
			&m_nSchemaUsage, 
            /*NULL*/ sizeof(m_nSchemaUsage),
			NULL);

How to repeat:
1 Create an ODBC data source to MySQL
2 connect to MySQL server version 8.0
3 execute SQLGetInfo with SQL_SCHEMA_TERM (incorrectly report "database")
4 execute SQLGetInfo with SQL_SCHEMA_USAGE (incorrctly report 31).

Suggested fix:
MySQL supports catalog but does not support schemas within a catalog.
This was working correctling in driver previous releases of the ODBC driver.
[22 Feb 8:45] MySQL Verification Team
Hello Farid Zidan,

Thank you for the bug report and feedback.
Because of multiple requests to treat MySQL databases as schemas the ODBC driver added such functionality. Also, it keeps backward compatibility with the historical way of representing databases as catalogs. Please check the following online manual page and get more information about how catalogs and schemas are handled by MySQL Connector/ODBC Driver:
https://docs.oracle.com/cd/E17952_01/connector-odbc-en/connector-odbc-usagenotes-functiona...

This is not a bug. Please set NO_CATALOG or NO_SCHEMA option according to what you need the driver to do.

Regards,
Ashwini Patil