Changeset: 9980d4cb9fa6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/9980d4cb9fa6 Modified Files: clients/odbc/ChangeLog clients/odbc/driver/ODBCQueries.h clients/odbc/driver/README clients/odbc/driver/SQLColumnPrivileges.c clients/odbc/driver/SQLColumns.c clients/odbc/driver/SQLForeignKeys.c clients/odbc/driver/SQLPrimaryKeys.c clients/odbc/driver/SQLProcedureColumns.c clients/odbc/driver/SQLProcedures.c clients/odbc/driver/SQLSpecialColumns.c clients/odbc/driver/SQLStatistics.c clients/odbc/driver/SQLTablePrivileges.c clients/odbc/driver/SQLTables.c clients/odbc/samples/metadata.c Branch: default Log Message:
Fixed issue in function SQLProcedureColumns(). When the argument ColumnName was not empty it generated an invalid SQL query which failed with error: SELECT: no such column 'c.name'. This has been resolved. Changed the column names case of the result sets as returned by SQLTables(), SQLColumns(), SQLSpecialColumns(), SQLPrimaryKeys(), SQLForeignKeys(), SQLStatistics(), SQLTablePrivileges(), SQLColumnPrivileges(), SQLProcedures() and SQLProcedureColumns(). The column names where all in lowercase but the ODBC specification defines them in uppercase, so changed them to uppercase. Also extended odbc metadata test program with invocations of SQLForeignKeys(), SQLTablePrivileges(), SQLColumnPrivileges(), SQLProcedures() and SQLProcedureColumns(). This identified an issue in SQLProcedureColumns(), which has also been fixed. diffs (truncated from 1332 to 300 lines): diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog --- a/clients/odbc/ChangeLog +++ b/clients/odbc/ChangeLog @@ -2,9 +2,17 @@ # This file is updated with Maddlog * Thu Jun 2 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> -- Fixed implementation of SQLGetInfo(hdbc, SQL_MAX_DRIVER_CONNECTIONS, - ...). It used to always return a value of 64. Now it returns the - MonetDB server value. +- Fixed issue in function SQLProcedureColumns(). When the argument ColumnName + was not empty it generated an invalid SQL query which failed with error: + SELECT: no such column 'c.name'. This has been resolved. +- Corrected implementation of SQLGetInfo(hdbc, SQL_MAX_DRIVER_CONNECTIONS, ...). + It used to always return 64. Now it returns the value from the MonetDB server. +- Changed the column names case of the result sets as returned by + SQLTables(), SQLColumns(), SQLSpecialColumns(), SQLPrimaryKeys(), + SQLForeignKeys(), SQLStatistics(), SQLTablePrivileges(), + SQLColumnPrivileges(), SQLProcedures() and SQLProcedureColumns(). The + column names where all in lowercase but the ODBC specification defines + them in uppercase, so changed them to uppercase. * Thu May 19 2022 Martin van Dinther <martin.van.dint...@monetdbsolutions.com> - Corrected SQLSpecialColumns(..., SQL_BEST_ROWID, ...). Previously it only diff --git a/clients/odbc/driver/ODBCQueries.h b/clients/odbc/driver/ODBCQueries.h --- a/clients/odbc/driver/ODBCQueries.h +++ b/clients/odbc/driver/ODBCQueries.h @@ -48,7 +48,7 @@ "when 'timetz' then %d " \ "when 'tinyint' then %d " \ "when 'varchar' then %d " \ - "end as data_type" + "end as \"DATA_TYPE\"" #define DATA_TYPE_ARGS \ SQL_BIGINT, SQL_LONGVARBINARY, SQL_BIT, SQL_WCHAR, \ SQL_WLONGVARCHAR, SQL_TYPE_DATE, SQL_DECIMAL, \ @@ -104,7 +104,7 @@ "when 'timetz' then 'TIME' " \ "when 'tinyint' then 'TINYINT' " \ "when 'varchar' then 'VARCHAR' " \ - "end as type_name" + "end as \"TYPE_NAME\"" #define COLUMN_SIZE(t) \ "case " #t ".type " \ @@ -134,7 +134,7 @@ "when 'timestamptz' then 23 " \ "when 'timetz' then 12 " \ "else " #t ".type_digits " \ - "end as column_size" + "end as \"COLUMN_SIZE\"" #define BUFFER_LENGTH(t) "case " #t ".type " \ "when 'bigint' then 20 " \ @@ -173,7 +173,7 @@ "when 'tinyint' then 4 " \ "when 'varchar' then 2 * " #t ".type_digits " \ "else " #t ".type_digits " \ - "end as buffer_length" + "end as \"BUFFER_LENGTH\"" #define DECIMAL_DIGITS(t) "case " #t ".type " \ "when 'bigint' then 0 " \ @@ -198,7 +198,7 @@ "when 'timetz' then " #t ".type_digits - 1 " \ "when 'tinyint' then 0 " \ "else cast(null as smallint) " \ - "end as decimal_digits" + "end as \"DECIMAL_DIGITS\"" #define NUM_PREC_RADIX(t) "case " #t ".type " \ "when 'bigint' then 2 " \ @@ -216,7 +216,7 @@ "when 'smallint' then 2 " \ "when 'tinyint' then 2 " \ "else cast(null as smallint) " \ - "end as num_prec_radix" + "end as \"NUM_PREC_RADIX\"" #define SQL_DATA_TYPE(t) \ "case " #t ".type " \ @@ -241,7 +241,7 @@ "when 'timetz' then %d " \ "when 'tinyint' then %d " \ "when 'varchar' then %d " \ - "end as sql_data_type" + "end as \"SQL_DATA_TYPE\"" #define SQL_DATA_TYPE_ARGS \ SQL_BIGINT, SQL_LONGVARBINARY, SQL_BIT, SQL_WCHAR, \ SQL_WLONGVARCHAR, SQL_DATETIME, SQL_INTERVAL, SQL_DECIMAL, SQL_DOUBLE, \ @@ -277,7 +277,7 @@ "when 'timestamptz' then %d " \ "when 'timetz' then %d " \ "else cast(null as smallint) " \ - "end as sql_datetime_sub" + "end as \"SQL_DATETIME_SUB\"" #define SQL_DATETIME_SUB_ARGS \ SQL_CODE_DATE, SQL_CODE_DAY, SQL_CODE_YEAR, SQL_CODE_YEAR_TO_MONTH, \ SQL_CODE_MONTH, SQL_CODE_DAY, SQL_CODE_DAY_TO_HOUR, \ @@ -295,4 +295,4 @@ "when 'clob' then 2 * " #t ".type_digits " \ "when 'blob' then " #t ".type_digits " \ "else cast(null as integer) " \ - "end as char_octet_length" + "end as \"CHAR_OCTET_LENGTH\"" diff --git a/clients/odbc/driver/README b/clients/odbc/driver/README --- a/clients/odbc/driver/README +++ b/clients/odbc/driver/README @@ -170,8 +170,8 @@ The next ODBC API functions are function - SQLTables() - SQLColumns() - SQLSpecialColumns() - - SQLPrimarykeys() - - SQLForeignkeys() + - SQLPrimaryKeys() + - SQLForeignKeys() - SQLStatistics() - SQLTablePrivileges() - SQLColumnPrivileges() diff --git a/clients/odbc/driver/SQLColumnPrivileges.c b/clients/odbc/driver/SQLColumnPrivileges.c --- a/clients/odbc/driver/SQLColumnPrivileges.c +++ b/clients/odbc/driver/SQLColumnPrivileges.c @@ -117,35 +117,35 @@ MNDBColumnPrivileges(ODBCStmt *stmt, goto nomem; /* SQLColumnPrivileges returns a table with the following columns: - table_cat VARCHAR - table_schem VARCHAR - table_name VARCHAR NOT NULL - column_name VARCHAR NOT NULL - grantor VARCHAR - grantee VARCHAR NOT NULL - privilege VARCHAR NOT NULL - is_grantable VARCHAR + TABLE_CAT VARCHAR + TABLE_SCHEM VARCHAR + TABLE_NAME VARCHAR NOT NULL + COLUMN_NAME VARCHAR NOT NULL + GRANTOR VARCHAR + GRANTEE VARCHAR NOT NULL + PRIVILEGE VARCHAR NOT NULL + IS_GRANTABLE VARCHAR */ pos += snprintf(query + pos, querylen - pos, - "select '%s' as table_cat, " - "s.name as table_schem, " - "t.name as table_name, " - "c.name as column_name, " + "select '%s' as \"TABLE_CAT\", " + "s.name as \"TABLE_SCHEM\", " + "t.name as \"TABLE_NAME\", " + "c.name as \"COLUMN_NAME\", " "case a.id " "when s.owner " "then '_SYSTEM' " "else g.name " - "end as grantor, " + "end as \"GRANTOR\", " "case a.name " "when 'public' then 'PUBLIC' " "else a.name " - "end as grantee, " - "pc.privilege_code_name as privilege, " + "end as \"GRANTEE\", " + "pc.privilege_code_name as \"PRIVILEGE\", " "case p.grantable " "when 1 then 'YES' " "when 0 then 'NO' " - "end as is_grantable " + "end as \"IS_GRANTABLE\" " "from sys.schemas as s, " "sys._tables as t, " "sys._columns as c, " @@ -197,7 +197,7 @@ MNDBColumnPrivileges(ODBCStmt *stmt, } /* add the ordering (exclude table_cat as it is the same for all rows) */ - pos += strcpy_len(query + pos, " order by table_schem, table_name, column_name, privilege", querylen - pos); + pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", \"TABLE_NAME\", \"COLUMN_NAME\", \"PRIVILEGE\"", querylen - pos); assert(pos <= querylen); /* query the MonetDB data dictionary tables */ diff --git a/clients/odbc/driver/SQLColumns.c b/clients/odbc/driver/SQLColumns.c --- a/clients/odbc/driver/SQLColumns.c +++ b/clients/odbc/driver/SQLColumns.c @@ -129,31 +129,31 @@ MNDBColumns(ODBCStmt *stmt, goto nomem; /* SQLColumns returns a table with the following columns: - VARCHAR table_cat - VARCHAR table_schem - VARCHAR table_name NOT NULL - VARCHAR column_name NOT NULL - SMALLINT data_type NOT NULL - VARCHAR type_name NOT NULL - INTEGER column_size - INTEGER buffer_length - SMALLINT decimal_digits - SMALLINT num_prec_radix - SMALLINT nullable NOT NULL - VARCHAR remarks - VARCHAR column_def - SMALLINT sql_data_type NOT NULL - SMALLINT sql_datetime_sub - INTEGER char_octet_length - INTEGER ordinal_position NOT NULL - VARCHAR is_nullable + VARCHAR TABLE_CAT + VARCHAR TABLE_SCHEM + VARCHAR TABLE_NAME NOT NULL + VARCHAR COLUMN_NAME NOT NULL + SMALLINT DATA_TYPE NOT NULL + VARCHAR TYPE_NAME NOT NULL + INTEGER COLUMN_SIZE + INTEGER BUFFER_LENGTH + SMALLINT DECIMAL_DIGITS + SMALLINT NUM_PREC_RADIX + SMALLINT NULLABLE NOT NULL + VARCHAR REMARKS + VARCHAR COLUMN_DEF + SMALLINT SQL_DATA_TYPE NOT NULL + SMALLINT SQL_DATETIME_SUB + INTEGER CHAR_OCTET_LENGTH + INTEGER ORDINAL_POSITION NOT NULL + VARCHAR IS_NULLABLE */ pos += snprintf(query + pos, querylen - pos, - "select '%s' as table_cat, " - "s.name as table_schem, " - "t.name as table_name, " - "c.name as column_name, " + "select '%s' as \"TABLE_CAT\", " + "s.name as \"TABLE_SCHEM\", " + "t.name as \"TABLE_NAME\", " + "c.name as \"COLUMN_NAME\", " DATA_TYPE(c) ", " TYPE_NAME(c) ", " COLUMN_SIZE(c) ", " @@ -163,17 +163,17 @@ MNDBColumns(ODBCStmt *stmt, "case c.\"null\" " "when true then cast(%d as smallint) " "when false then cast(%d as smallint) " - "end as nullable, " - "%s as remarks, " - "c.\"default\" as column_def, " + "end as \"NULLABLE\", " + "%s as \"REMARKS\", " + "c.\"default\" as \"COLUMN_DEF\", " SQL_DATA_TYPE(c) ", " SQL_DATETIME_SUB(c) ", " CHAR_OCTET_LENGTH(c) ", " - "cast(c.number + 1 as integer) as ordinal_position, " + "cast(c.number + 1 as integer) as \"ORDINAL_POSITION\", " "case c.\"null\" " "when true then cast('YES' as varchar(3)) " "when false then cast('NO' as varchar(3)) " - "end as is_nullable " + "end as \"IS_NULLABLE\" " "from sys.schemas s, " "sys.tables t, " "sys.columns c%s " @@ -243,7 +243,7 @@ MNDBColumns(ODBCStmt *stmt, } /* add the ordering (exclude table_cat as it is the same for all rows) */ - pos += strcpy_len(query + pos, " order by table_schem, table_name, ordinal_position", querylen - pos); + pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", \"TABLE_NAME\", \"ORDINAL_POSITION\"", querylen - pos); /* query the MonetDB data dictionary tables */ rc = MNDBExecDirect(stmt, (SQLCHAR *) query, (SQLINTEGER) pos); diff --git a/clients/odbc/driver/SQLForeignKeys.c b/clients/odbc/driver/SQLForeignKeys.c --- a/clients/odbc/driver/SQLForeignKeys.c +++ b/clients/odbc/driver/SQLForeignKeys.c @@ -149,37 +149,37 @@ MNDBForeignKeys(ODBCStmt *stmt, goto nomem; /* SQLForeignKeys returns a table with the following columns: - VARCHAR pktable_cat - VARCHAR pktable_schem - VARCHAR pktable_name NOT NULL - VARCHAR pkcolumn_name NOT NULL - VARCHAR fktable_cat - VARCHAR fktable_schem - VARCHAR fktable_name NOT NULL - VARCHAR fkcolumn_name NOT NULL - SMALLINT key_seq NOT NULL - SMALLINT update_rule - SMALLINT delete_rule - VARCHAR fk_name - VARCHAR pk_name - SMALLINT deferrability + VARCHAR PKTABLE_CAT + VARCHAR PKTABLE_SCHEM + VARCHAR PKTABLE_NAME NOT NULL + VARCHAR PKCOLUMN_NAME NOT NULL + VARCHAR FKTABLE_CAT + VARCHAR FKTABLE_SCHEM + VARCHAR FKTABLE_NAME NOT NULL _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org