pg.ddx.io pgsql-odbc@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Regression tests for functions of info.c 5+ messages / 2 participants [nested] [flat]
* Regression tests for functions of info.c @ 2014-03-13 13:52 Michael Paquier <michael.paquier@gmail.com> 2014-03-13 14:01 ` Re: Regression tests for functions of info.c Heikki Linnakangas <hlinnakangas@vmware.com> 0 siblings, 1 reply; 5+ messages in thread From: Michael Paquier @ 2014-03-13 13:52 UTC (permalink / raw) To: pgsql-odbc Hi all, Please find attached a patch adding regression tests for the functions in info.c. The following functions, that use hardcoded column names for their results are checked: - SQLGetTypeInfo - SQLTables - SQLColumns - SQLSpecialColumns - SQLStatistics - SQLPrimaryKeys - SQLForeignKeys - SQLProcedureColumns - SQLTablePrivileges Note that the number of columns used for some of those functions, like SQLGetTypeInfo, has increased since 0x0300, so those regression tests are not compatible with versions of odbc older than 0x0300 and would need an alternative output. The patch attached does not have the alternative output for ODBCVER < 0x0300. Do we honestly need it? Regards -- Michael -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc Attachments:^ permalink raw reply [nested|flat] 5+ messages in thread20140313_pgodbc_info_regression.patch (text/plain, 8.8K) download
commit c530fd3f2308a05aedfe23b339d6978559d8bcf6 Author: Michael Paquier <michael@otacoo.com> Date: Thu Mar 13 22:44:29 2014 +0900 Add regression tests for all functions in info.c The following functions, using hardcoded column names, are checked with this new test: - SQLGetTypeInfo - SQLTables - SQLColumns - SQLSpecialColumns - SQLStatistics - SQLPrimaryKeys - SQLForeignKeys - SQLProcedureColumns - SQLTablePrivileges diff --git a/test/Makefile b/test/Makefile index ba94136..a822bcd 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,7 @@ TESTS = connect stmthandles select commands multistmt getresult prepare \ params notice arraybinding insertreturning dataatexecution \ boolsaschar cvtnulldate alter quotes cursors positioned-update \ - catalogfunctions bindcol lfconversion cte + catalogfunctions bindcol lfconversion cte information TESTBINS = $(patsubst %,src/%-test, $(TESTS)) TESTSQLS = $(patsubst %,sql/%.sql, $(TESTS)) diff --git a/test/expected/information.out b/test/expected/information.out new file mode 100644 index 0000000..73d9541 --- /dev/null +++ b/test/expected/information.out @@ -0,0 +1,146 @@ +\! ./src/information-test +connected +Columns obtained for SQLGetTypeInfo: +Column 0: TYPE_NAME +Column 1: DATA_TYPE +Column 2: PRECISION +Column 3: LITERAL_PREFIX +Column 4: LITERAL_SUFFIX +Column 5: CREATE_PARAMS +Column 6: NULLABLE +Column 7: CASE_SENSITIVE +Column 8: SEARCHABLE +Column 9: UNSIGNED_ATTRIBUTE +Column 10: MONEY +Column 11: AUTO_INCREMENT +Column 12: LOCAL_TYPE_NAME +Column 13: MINIMUM_SCALE +Column 14: MAXIMUM_SCALE +Column 15: SQL_DATA_TYPE +Column 16: SQL_DATETIME_SUB +Column 17: NUM_PREC_RADIX +Column 18: INTERVAL_PRECISION +End of column list for SQLGetTypeInfo + +Columns obtained for SQLTables: +Column 0: TABLE_QUALIFIER +Column 1: TABLE_OWNER +Column 2: TABLE_NAME +Column 3: TABLE_TYPE +Column 4: REMARKS +End of column list for SQLTables + +Columns obtained for SQLColumns: +Column 0: TABLE_QUALIFIER +Column 1: TABLE_OWNER +Column 2: TABLE_NAME +Column 3: COLUMN_NAME +Column 4: DATA_TYPE +Column 5: TYPE_NAME +Column 6: PRECISION +Column 7: LENGTH +Column 8: SCALE +Column 9: RADIX +Column 10: NULLABLE +Column 11: REMARKS +Column 12: COLUMN_DEF +Column 13: SQL_DATA_TYPE +Column 14: SQL_DATETIME_SUB +Column 15: CHAR_OCTET_LENGTH +Column 16: ORDINAL_POSITION +Column 17: IS_NULLABLE +Column 18: DISPLAY_SIZE +Column 19: FIELD_TYPE +Column 20: AUTO_INCREMENT +Column 21: PHYSICAL NUMBER +Column 22: TABLE OID +Column 23: BASE TYPEID +Column 24: TYPMOD +End of column list for SQLColumns + +Columns obtained for SQLSpecialColumns: +Column 0: SCOPE +Column 1: COLUMN_NAME +Column 2: DATA_TYPE +Column 3: TYPE_NAME +Column 4: PRECISION +Column 5: LENGTH +Column 6: SCALE +Column 7: PSEUDO_COLUMN +End of column list for SQLSpecialColumns + +Columns obtained for SQLStatistics: +Column 0: TABLE_QUALIFIER +Column 1: TABLE_OWNER +Column 2: TABLE_NAME +Column 3: NON_UNIQUE +Column 4: INDEX_QUALIFIER +Column 5: INDEX_NAME +Column 6: TYPE +Column 7: SEQ_IN_INDEX +Column 8: COLUMN_NAME +Column 9: COLLATION +Column 10: CARDINALITY +Column 11: PAGES +Column 12: FILTER_CONDITION +End of column list for SQLStatistics + +Columns obtained for SQLPrimaryKeys: +Column 0: TABLE_QUALIFIER +Column 1: TABLE_OWNER +Column 2: TABLE_NAME +Column 3: COLUMN_NAME +Column 4: KEY_SEQ +Column 5: PK_NAME +End of column list for SQLPrimaryKeys + +Columns obtained for SQLForeignKeys: +Column 0: pktable_cat +Column 1: pktable_schem +Column 2: pktable_name +Column 3: pkcolumn_name +Column 4: fktable_cat +Column 5: fktable_schem +Column 6: fktable_name +Column 7: fkcolumn_name +Column 8: key_seq +Column 9: update_rule +Column 10: delete_rule +Column 11: fk_name +Column 12: pk_name +Column 13: deferrablity +End of column list for SQLForeignKeys + +Columns obtained for SQLProcedureColumns: +Column 0: PROCEDURE_CAT +Column 1: PROCEDUR_SCHEM +Column 2: PROCEDURE_NAME +Column 3: COLUMN_NAME +Column 4: COLUMN_TYPE +Column 5: DATA_TYPE +Column 6: TYPE_NAME +Column 7: COLUMN_SIZE +Column 8: BUFFER_LENGTH +Column 9: DECIMAL_DIGITS +Column 10: NUM_PREC_RADIX +Column 11: NULLABLE +Column 12: REMARKS +Column 13: COLUMN_DEF +Column 14: SQL_DATA_TYPE +Column 15: SQL_DATETIME_SUB +Column 16: CHAR_OCTET_LENGTH +Column 17: ORDINAL_POSITION +Column 18: IS_NULLABLE +End of column list for SQLProcedureColumns + +Columns obtained for SQLTablePrivileges: +Column 0: TABLE_CAT +Column 1: TABLE_SCHEM +Column 2: TABLE_NAME +Column 3: GRANTOR +Column 4: GRANTEE +Column 5: PRIVILEGE +Column 6: IS_GRANTABLE +End of column list for SQLTablePrivileges + +disconnecting diff --git a/test/src/information-test.c b/test/src/information-test.c new file mode 100644 index 0000000..90e040f --- /dev/null +++ b/test/src/information-test.c @@ -0,0 +1,159 @@ +/* + * Regression test information + * + * Check the following list of functions that use hardcoded column + * names: + * - SQLGetTypeInfo + * - SQLTables + * - SQLColumns + * - SQLSpecialColumns + * - SQLStatistics + * - SQLPrimaryKeys + * - SQLForeignKeys + * - SQLProcedureColumns + * - SQLTablePrivileges + * The data that is queried here is not really important... + */ +#include <stdio.h> +#include <stdlib.h> + +#include "common.h" + +/* + * print_columns + * Print a list of column names associated with the given statement. + */ +void +print_columns(HSTMT hstmt, char *test) +{ + SQLSMALLINT num_columns = 0; + SQLPOINTER *labels = NULL; + SQLRETURN rc; + char buf[128]; + int i; + + /* Get number of columns obtained */ + rc = SQLNumResultCols(hstmt, &num_columns); + CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt); + + /* Print each column */ + printf("Columns obtained for %s:\n", test); + for (i = 0; i < num_columns; i++) + { + rc = SQLColAttribute(hstmt, + (SQLUSMALLINT) i + 1, + SQL_DESC_LABEL, + buf, + 128, + NULL, + NULL); + CHECK_STMT_RESULT(rc, "SQLColAttribute failed", hstmt); + printf("Column %d: %s\n", i, (char *) buf); + } + printf("End of column list for %s\n\n", test); + + /* Clean up */ + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); +} + +int +main(int argc, char **argv) +{ + SQLRETURN rc; + HSTMT hstmt = SQL_NULL_HSTMT; + char buf[128]; + int buffer_size = 1024; + SQLSMALLINT num_columns = 0; + int i; + SQLPOINTER *labels = NULL; + test_connect(); + + rc = SQLAllocStmt(conn, &hstmt); + if (!SQL_SUCCEEDED(rc)) + { + print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn); + exit(1); + } + + /* Check for SQLGetTypeInfo */ + rc = SQLGetTypeInfo(hstmt, SQL_VARCHAR); + CHECK_STMT_RESULT(rc, "SQLGetTypeInfo failed", hstmt); + print_columns(hstmt, "SQLGetTypeInfo"); + + /* Check for SQLTables */ + rc = SQLTables(hstmt, + (SQLCHAR *) SQL_ALL_CATALOGS, SQL_NTS, + NULL, 0, + NULL, 0, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); + print_columns(hstmt, "SQLTables"); + + /* Check for SQLColumns */ + rc = SQLColumns(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + (SQLCHAR *) "pg_class", SQL_NTS, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLColumns failed", hstmt); + print_columns(hstmt, "SQLColumns"); + + /* Check for SQLSpecialColumns */ + rc = SQLSpecialColumns(hstmt, SQL_BEST_ROWID, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + (SQLCHAR *) "pg_class", SQL_NTS, + SQL_SCOPE_CURROW, + SQL_NULLABLE); + CHECK_STMT_RESULT(rc, "SQLSpecialColumns failed", hstmt); + print_columns(hstmt, "SQLSpecialColumns"); + + /* Check for SQLStatistics */ + rc = SQLStatistics(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + (SQLCHAR *) "pg_class", SQL_NTS, + 0, 0); + CHECK_STMT_RESULT(rc, "SQLStatistics failed", hstmt); + print_columns(hstmt, "SQLStatistics"); + + /* Check for SQLPrimaryKeys */ + rc = SQLPrimaryKeys(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + (SQLCHAR *) "pg_class", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLPrimaryKeys failed", hstmt); + print_columns(hstmt, "SQLPrimaryKeys"); + + /* Check for SQLForeignKeys */ + rc = SQLForeignKeys(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + (SQLCHAR *) "pg_class", SQL_NTS, + NULL, 0, + NULL, 0, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLForeignKeys failed", hstmt); + print_columns(hstmt, "SQLForeignKeys"); + + /* Check for SQLProcedureColumns */ + rc = SQLProcedureColumns(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", SQL_NTS, + NULL, 0, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); + print_columns(hstmt, "SQLProcedureColumns"); + + /* Check for SQLTablePrivileges */ + rc = SQLTablePrivileges(hstmt, + NULL, 0, + (SQLCHAR *) "pg_catalog", 0, + (SQLCHAR *) "pg_class", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLTablePrivileges failed", hstmt); + print_columns(hstmt, "SQLTablePrivileges"); + + /* Clean up */ + test_disconnect(); +}
* Re: Regression tests for functions of info.c 2014-03-13 13:52 Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> @ 2014-03-13 14:01 ` Heikki Linnakangas <hlinnakangas@vmware.com> 2014-03-13 14:20 ` Re: Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 2014-03-18 13:08 ` Re: Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 0 siblings, 2 replies; 5+ messages in thread From: Heikki Linnakangas @ 2014-03-13 14:01 UTC (permalink / raw) To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc On 03/13/2014 03:52 PM, Michael Paquier wrote: > Please find attached a patch adding regression tests for the functions > in info.c. The following functions, that use hardcoded column names > for their results are checked: > - SQLGetTypeInfo > - SQLTables > - SQLColumns > - SQLSpecialColumns > - SQLStatistics > - SQLPrimaryKeys > - SQLForeignKeys > - SQLProcedureColumns > - SQLTablePrivileges > Note that the number of columns used for some of those functions, like > SQLGetTypeInfo, has increased since 0x0300, so those regression tests > are not compatible with versions of odbc older than 0x0300 and would > need an alternative output. Hmm, that's fine as far as it goes, but surely we need to test that they actually return correct data, not just the column names? I envisioned the "catalogfunctions" test case to eventually cover these, although at the moment it only tests SQLTables. The ODBC standard calls these "catalog functions", per http://msdn.microsoft.com/en-us/library/ms711722%28v=vs.85%29.aspx. From that list, you're missing SQLColumnPrivileges and SQLProcedures. > The patch attached does not have the > alternative output for ODBCVER < 0x0300. Do we honestly need it? Certainly not after you cleanup that removes #ifdefs :-). If we still care for ODBCVER < 0x0300 in 9.3, we could just not merge this until the cleanup, but I don't think we care. If someone's building with ODBCVER < 0x0300, he can just ignore the failure. - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Regression tests for functions of info.c 2014-03-13 13:52 Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 2014-03-13 14:01 ` Re: Regression tests for functions of info.c Heikki Linnakangas <hlinnakangas@vmware.com> @ 2014-03-13 14:20 ` Michael Paquier <michael.paquier@gmail.com> 1 sibling, 0 replies; 5+ messages in thread From: Michael Paquier @ 2014-03-13 14:20 UTC (permalink / raw) To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc On Thu, Mar 13, 2014 at 11:01 PM, Heikki Linnakangas <hlinnakangas@vmware.com> wrote: > Hmm, that's fine as far as it goes, but surely we need to test that they > actually return correct data, not just the column names? The point of this test was to cover the issue related to the column names: e: http://www.postgresql.org/message-id/5315E622.2010904@ntlworld.com. If we want to test all those functions by checking their data, we will need roughly to either choose and/or create one/two table(s) with pk and fk, a procedure, a data type, and an index for SQLStatistics. I imagine that raw data will be more helpful than querying catalog in this case except for the data type. > I envisioned the "catalogfunctions" test case to eventually cover these, > although at the moment it only tests SQLTables. The ODBC standard calls > these "catalog functions", per > http://msdn.microsoft.com/en-us/library/ms711722%28v=vs.85%29.aspx. From > that list, you're missing SQLColumnPrivileges and SQLProcedures. I lack of caffeine. -- Michael -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Regression tests for functions of info.c 2014-03-13 13:52 Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 2014-03-13 14:01 ` Re: Regression tests for functions of info.c Heikki Linnakangas <hlinnakangas@vmware.com> @ 2014-03-18 13:08 ` Michael Paquier <michael.paquier@gmail.com> 2014-03-18 20:28 ` Re: Regression tests for functions of info.c Heikki Linnakangas <hlinnakangas@vmware.com> 1 sibling, 1 reply; 5+ messages in thread From: Michael Paquier @ 2014-03-18 13:08 UTC (permalink / raw) To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc On Thu, Mar 13, 2014 at 11:01 PM, Heikki Linnakangas <hlinnakangas@vmware.com> wrote: > On 03/13/2014 03:52 PM, Michael Paquier wrote: >> >> Please find attached a patch adding regression tests for the functions >> in info.c. The following functions, that use hardcoded column names >> for their results are checked: >> - SQLGetTypeInfo >> - SQLTables >> - SQLColumns >> - SQLSpecialColumns >> - SQLStatistics >> - SQLPrimaryKeys >> - SQLForeignKeys >> - SQLProcedureColumns >> - SQLTablePrivileges >> Note that the number of columns used for some of those functions, like >> SQLGetTypeInfo, has increased since 0x0300, so those regression tests >> are not compatible with versions of odbc older than 0x0300 and would >> need an alternative output. > > > Hmm, that's fine as far as it goes, but surely we need to test that they > actually return correct data, not just the column names? > > I envisioned the "catalogfunctions" test case to eventually cover these, > although at the moment it only tests SQLTables. The ODBC standard calls > these "catalog functions", per > http://msdn.microsoft.com/en-us/library/ms711722%28v=vs.85%29.aspx. From > that list, you're missing SQLColumnPrivileges and SQLProcedures. OK, I have been working more on this patch and have integrated all the tests directly in catalogfunctions. I have also extended as well the functions in common.c to be able to print results for arrays of column IDs. I found that this became necessary as the current logic is able to print results only for all the columns, and there are some data like table OID or user name that we do not want as output in the test suite. Also, I think that I have found a bug, or let's say a limitation with SQLColumnPrivileges, which does not work with unixodbc 2.3.2. I tried to use this function on LInux and OSX, each time it failed with the following error: ! IM001=[unixODBC][Driver Manager]Driver does not support this function The patch I am attaching has some commented code for the test case of SQLColumnPrivileges, but I disabled it. For example I tried to call it like that but it failed: rc = SQLColumnPrivileges(hstmt, NULL, 0, (SQLCHAR *) "public", SQL_NTS, (SQLCHAR *) "testtab1", SQL_NTS, (SQLCHAR *) "id", SQL_NTS); Comments and feedback are welcome. -- Michael -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc Attachments:^ permalink raw reply [nested|flat] 5+ messages in thread20140318_catalogfuncs_regress_v2.patch (text/plain, 20.6K) download
diff --git a/test/expected/catalogfunctions.out b/test/expected/catalogfunctions.out index 914a8a1..dba7d55 100644 --- a/test/expected/catalogfunctions.out +++ b/test/expected/catalogfunctions.out @@ -1,10 +1,192 @@ \! ./src/catalogfunctions-test connected +Check for SQLTypeInfo +Result set metadata: +TYPE_NAME: VARCHAR(128) digits: 0, nullable +DATA_TYPE: SMALLINT(5) digits: 0, nullable +PRECISION: INTEGER(10) digits: 0, nullable +LITERAL_PREFIX: VARCHAR(128) digits: 0, nullable +LITERAL_SUFFIX: VARCHAR(128) digits: 0, nullable +CREATE_PARAMS: VARCHAR(128) digits: 0, nullable +NULLABLE: SMALLINT(5) digits: 0, nullable +CASE_SENSITIVE: SMALLINT(5) digits: 0, nullable +SEARCHABLE: SMALLINT(5) digits: 0, nullable +UNSIGNED_ATTRIBUTE: SMALLINT(5) digits: 0, nullable +MONEY: SMALLINT(5) digits: 0, nullable +AUTO_INCREMENT: SMALLINT(5) digits: 0, nullable +LOCAL_TYPE_NAME: VARCHAR(128) digits: 0, nullable +MINIMUM_SCALE: SMALLINT(5) digits: 0, nullable +MAXIMUM_SCALE: SMALLINT(5) digits: 0, nullable +SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable +SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable +NUM_PREC_RADIX: INTEGER(10) digits: 0, nullable +INTERVAL_PRECISION: SMALLINT(5) digits: 0, nullable +Result set: +varchar 12 255 ' ' max. length 1 1 3 NULL 0 NULL NULL NULL NULL 12 NULL NULL 0 +Check for SQLTables +Result set metadata: +TABLE_QUALIFIER: VARCHAR(128) digits: 0, nullable +TABLE_OWNER: VARCHAR(128) digits: 0, nullable +TABLE_NAME: VARCHAR(128) digits: 0, nullable +TABLE_TYPE: VARCHAR(128) digits: 0, nullable +REMARKS: VARCHAR(254) digits: 0, nullable Result set: contrib_regression public booltab TABLE contrib_regression public byteatab TABLE contrib_regression public intervaltable TABLE contrib_regression public testtab1 TABLE +contrib_regression public testtab_fk TABLE +Check for SQLColumns +Result set metadata: +TABLE_QUALIFIER: VARCHAR(128) digits: 0, nullable +TABLE_OWNER: VARCHAR(128) digits: 0, nullable +TABLE_NAME: VARCHAR(128) digits: 0, nullable +COLUMN_NAME: VARCHAR(128) digits: 0, nullable +DATA_TYPE: SMALLINT(5) digits: 0, nullable +TYPE_NAME: VARCHAR(128) digits: 0, nullable +PRECISION: INTEGER(10) digits: 0, nullable +LENGTH: INTEGER(10) digits: 0, nullable +SCALE: SMALLINT(5) digits: 0, nullable +RADIX: SMALLINT(5) digits: 0, nullable +NULLABLE: SMALLINT(5) digits: 0, nullable +REMARKS: VARCHAR(254) digits: 0, nullable +COLUMN_DEF: VARCHAR(254) digits: 0, nullable +SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable +SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable +CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable +ORDINAL_POSITION: INTEGER(10) digits: 0, nullable +IS_NULLABLE: VARCHAR(254) digits: 0, nullable +DISPLAY_SIZE: INTEGER(10) digits: 0, nullable +FIELD_TYPE: INTEGER(10) digits: 0, nullable +AUTO_INCREMENT: INTEGER(10) digits: 0, nullable +PHYSICAL NUMBER: SMALLINT(5) digits: 0, nullable +TABLE OID: INTEGER(10) digits: 0, nullable +BASE TYPEID: INTEGER(10) digits: 0, nullable +TYPMOD: INTEGER(10) digits: 0, nullable +Result set: +contrib_regression public booltab id 4 int4 +contrib_regression public booltab t 12 varchar +contrib_regression public booltab b 12 bool +contrib_regression public byteatab id 4 int4 +contrib_regression public byteatab t -3 bytea +contrib_regression public intervaltable id 4 int4 +contrib_regression public intervaltable iv 12 interval +contrib_regression public intervaltable d 12 varchar +contrib_regression public testtab1 id 4 int4 +contrib_regression public testtab1 t 12 varchar +contrib_regression public testtab1_pkey id 4 int4 +contrib_regression public testtab_fk id 4 int4 +contrib_regression public testtab_fk t 12 varchar +Check for SQLSpecialColumns +Result set metadata: +SCOPE: SMALLINT(5) digits: 0, nullable +COLUMN_NAME: VARCHAR(128) digits: 0, nullable +DATA_TYPE: SMALLINT(5) digits: 0, nullable +TYPE_NAME: VARCHAR(128) digits: 0, nullable +PRECISION: INTEGER(10) digits: 0, nullable +LENGTH: INTEGER(10) digits: 0, nullable +SCALE: SMALLINT(5) digits: 0, nullable +PSEUDO_COLUMN: SMALLINT(5) digits: 0, nullable +Result set: +NULL xmin 4 xid 10 4 0 2 +Check for SQLStatistics +Result set metadata: +TABLE_QUALIFIER: VARCHAR(128) digits: 0, nullable +TABLE_OWNER: VARCHAR(128) digits: 0, nullable +TABLE_NAME: VARCHAR(128) digits: 0, nullable +NON_UNIQUE: SMALLINT(5) digits: 0, nullable +INDEX_QUALIFIER: VARCHAR(128) digits: 0, nullable +INDEX_NAME: VARCHAR(128) digits: 0, nullable +TYPE: SMALLINT(5) digits: 0, nullable +SEQ_IN_INDEX: SMALLINT(5) digits: 0, nullable +COLUMN_NAME: VARCHAR(128) digits: 0, nullable +COLLATION: CHAR(1) digits: 0, nullable +CARDINALITY: INTEGER(10) digits: 0, nullable +PAGES: INTEGER(10) digits: 0, nullable +FILTER_CONDITION: VARCHAR(128) digits: 0, nullable +Result set: +contrib_regression public testtab1 0 public testtab1_pkey 3 1 id A NULL NULL NULL +Check for SQLPrimaryKeys +Result set metadata: +TABLE_QUALIFIER: VARCHAR(128) digits: 0, nullable +TABLE_OWNER: VARCHAR(128) digits: 0, nullable +TABLE_NAME: VARCHAR(128) digits: 0, nullable +COLUMN_NAME: VARCHAR(128) digits: 0, nullable +KEY_SEQ: SMALLINT(5) digits: 0, nullable +PK_NAME: VARCHAR(128) digits: 0, nullable +Result set: +contrib_regression public testtab1 id 1 testtab1_pkey +Check for SQLForeignKeys +Result set metadata: +pktable_cat: VARCHAR(64) digits: 0, nullable +pktable_schem: VARCHAR(64) digits: 0, not nullable +pktable_name: VARCHAR(64) digits: 0, not nullable +pkcolumn_name: VARCHAR(64) digits: 0, not nullable +fktable_cat: VARCHAR(64) digits: 0, nullable +fktable_schem: VARCHAR(64) digits: 0, not nullable +fktable_name: VARCHAR(64) digits: 0, not nullable +fkcolumn_name: VARCHAR(64) digits: 0, not nullable +key_seq: SMALLINT(5) digits: 0, nullable +update_rule: SMALLINT(5) digits: 0, nullable +delete_rule: SMALLINT(5) digits: 0, nullable +fk_name: VARCHAR(64) digits: 0, not nullable +pk_name: VARCHAR(64) digits: 0, not nullable +deferrablity: SMALLINT(5) digits: 0, nullable +Result set: +contrib_regression public testtab1 id contrib_regression public testtab_fk id 1 3 3 testtab_fk_id_fkey testtab1_pkey 7 +Check for SQLProcedures +Result set metadata: +procedure_cat: VARCHAR(255) digits: 0, nullable +procedure_schem: VARCHAR(64) digits: 0, not nullable +procedure_name: VARCHAR(64) digits: 0, not nullable +num_input_params: VARCHAR(255) digits: 0, nullable +num_output_params: VARCHAR(255) digits: 0, nullable +num_result_sets: VARCHAR(255) digits: 0, nullable +remarks: VARCHAR(255) digits: 0, nullable +procedure_type: SMALLINT(5) digits: 0, nullable +Result set: + public simple_add 2 +Check for SQLProcedureColumns +Result set metadata: +PROCEDURE_CAT: VARCHAR(128) digits: 0, nullable +PROCEDUR_SCHEM: VARCHAR(128) digits: 0, nullable +PROCEDURE_NAME: VARCHAR(128) digits: 0, nullable +COLUMN_NAME: VARCHAR(128) digits: 0, nullable +COLUMN_TYPE: SMALLINT(5) digits: 0, nullable +DATA_TYPE: SMALLINT(5) digits: 0, nullable +TYPE_NAME: VARCHAR(128) digits: 0, nullable +COLUMN_SIZE: INTEGER(10) digits: 0, nullable +BUFFER_LENGTH: INTEGER(10) digits: 0, nullable +DECIMAL_DIGITS: SMALLINT(5) digits: 0, nullable +NUM_PREC_RADIX: SMALLINT(5) digits: 0, nullable +NULLABLE: SMALLINT(5) digits: 0, nullable +REMARKS: VARCHAR(128) digits: 0, nullable +COLUMN_DEF: VARCHAR(128) digits: 0, nullable +SQL_DATA_TYPE: SMALLINT(5) digits: 0, nullable +SQL_DATETIME_SUB: SMALLINT(5) digits: 0, nullable +CHAR_OCTET_LENGTH: INTEGER(10) digits: 0, nullable +ORDINAL_POSITION: INTEGER(10) digits: 0, nullable +IS_NULLABLE: VARCHAR(128) digits: 0, nullable +Result set: +contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 1 +contrib_regression public simple_add 1 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 2 +contrib_regression public simple_add 4 4 int4 10 4 0 10 2 NULL NULL 4 NULL NULL 3 +Check for SQLTablePrivileges +Result set metadata: +TABLE_CAT: VARCHAR(128) digits: 0, nullable +TABLE_SCHEM: VARCHAR(128) digits: 0, nullable +TABLE_NAME: VARCHAR(128) digits: 0, nullable +GRANTOR: VARCHAR(128) digits: 0, nullable +GRANTEE: VARCHAR(128) digits: 0, nullable +PRIVILEGE: VARCHAR(128) digits: 0, nullable +IS_GRANTABLE: VARCHAR(128) digits: 0, nullable +Result set: +contrib_regression public testtab1 _SYSTEM INSERT YES +contrib_regression public testtab1 _SYSTEM SELECT YES +contrib_regression public testtab1 _SYSTEM UPDATE YES +contrib_regression public testtab1 _SYSTEM DELETE YES +contrib_regression public testtab1 _SYSTEM REFERENCES YES Result set: contrib_regression public testtab1 TABLE +contrib_regression public testtab_fk TABLE disconnecting diff --git a/test/expected/sampletables.out b/test/expected/sampletables.out index 51b9073..e4fcb71 100644 --- a/test/expected/sampletables.out +++ b/test/expected/sampletables.out @@ -1,8 +1,12 @@ -- This file creates some tables to be used in the tests -CREATE TABLE testtab1 (id integer, t varchar(20)); +CREATE TABLE testtab1 (id integer PRIMARY KEY, t varchar(20)); INSERT INTO testtab1 VALUES (1, 'foo'); INSERT INTO testtab1 VALUES (2, 'bar'); INSERT INTO testtab1 VALUES (3, 'foobar'); +CREATE TABLE testtab_fk (id integer REFERENCES testtab1, t varchar(20)); +INSERT INTO testtab_fk VALUES (1, 'hoge'); +INSERT INTO testtab_fk VALUES (2, 'pogno'); +INSERT INTO testtab_fk VALUES (3, 'poco'); CREATE TABLE byteatab (id integer, t bytea); INSERT INTO byteatab VALUES (1, E'\\001\\002\\003\\004\\005\\006\\007\\010'::bytea); INSERT INTO byteatab VALUES (2, 'bar'); @@ -19,3 +23,7 @@ INSERT INTO booltab VALUES (2, 'yes', true); INSERT INTO booltab VALUES (3, 'true', true); INSERT INTO booltab VALUES (4, 'false', false); INSERT INTO booltab VALUES (5, 'not', false); +-- Procedure for catalog function checks +CREATE FUNCTION simple_add(in int, in int, out int) +AS $$ SELECT $1 + $2; +$$ LANGUAGE SQL; diff --git a/test/sql/sampletables.sql b/test/sql/sampletables.sql index 78a7eb6..a917de7 100644 --- a/test/sql/sampletables.sql +++ b/test/sql/sampletables.sql @@ -1,10 +1,15 @@ -- This file creates some tables to be used in the tests -CREATE TABLE testtab1 (id integer, t varchar(20)); +CREATE TABLE testtab1 (id integer PRIMARY KEY, t varchar(20)); INSERT INTO testtab1 VALUES (1, 'foo'); INSERT INTO testtab1 VALUES (2, 'bar'); INSERT INTO testtab1 VALUES (3, 'foobar'); +CREATE TABLE testtab_fk (id integer REFERENCES testtab1, t varchar(20)); +INSERT INTO testtab_fk VALUES (1, 'hoge'); +INSERT INTO testtab_fk VALUES (2, 'pogno'); +INSERT INTO testtab_fk VALUES (3, 'poco'); + CREATE TABLE byteatab (id integer, t bytea); INSERT INTO byteatab VALUES (1, E'\\001\\002\\003\\004\\005\\006\\007\\010'::bytea); INSERT INTO byteatab VALUES (2, 'bar'); @@ -23,3 +28,8 @@ INSERT INTO booltab VALUES (2, 'yes', true); INSERT INTO booltab VALUES (3, 'true', true); INSERT INTO booltab VALUES (4, 'false', false); INSERT INTO booltab VALUES (5, 'not', false); + +-- Procedure for catalog function checks +CREATE FUNCTION simple_add(in int, in int, out int) +AS $$ SELECT $1 + $2; +$$ LANGUAGE SQL; diff --git a/test/src/catalogfunctions-test.c b/test/src/catalogfunctions-test.c index 180d1f1..3d2d9ac 100644 --- a/test/src/catalogfunctions-test.c +++ b/test/src/catalogfunctions-test.c @@ -1,16 +1,35 @@ +/* + * This test is used to check the output and processing of the catalog + * functions listed as below: + * - SQLGetTypeInfo + * - SQLTables + * - SQLColumns + * - SQLSpecialColumns + * - SQLStatistics + * - SQLPrimaryKeys + * - SQLForeignKeys + * - SQLProcedureColumns + * - SQLTablePrivileges + * - SQLColumnPrivileges + * - SQLProcedures + */ #include <string.h> #include <stdio.h> #include <stdlib.h> #include "common.h" -int main(int argc, char **argv) +int +main(int argc, char **argv) { int rc; HSTMT hstmt = SQL_NULL_HSTMT; char sql[100000]; char *sqlend; int i; + /* Cases where output is limited to relevant information only */ + SQLSMALLINT sql_tab_privileges_ids[6] = {1, 2, 3, 4, 6, 7}; + SQLSMALLINT sql_column_ids[6] = {1, 2, 3, 4, 5, 6}; test_connect(); @@ -21,22 +40,158 @@ int main(int argc, char **argv) exit(1); } - rc = SQLTables(hstmt, "", SQL_NTS, - "public", SQL_NTS, - "%", SQL_NTS, - "TABLE", SQL_NTS); + /* Check for SQLGetTypeInfo */ + printf("Check for SQLTypeInfo\n"); + rc = SQLGetTypeInfo(hstmt, SQL_VARCHAR); + CHECK_STMT_RESULT(rc, "SQLGetTypeInfo failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + /* Check for SQLTables */ + printf("Check for SQLTables\n"); + rc = SQLTables(hstmt, NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "%", SQL_NTS, + (SQLCHAR *) "TABLE", SQL_NTS); CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLColumns */ + printf("Check for SQLColumns\n"); + rc = SQLColumns(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "%", SQL_NTS, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLColumns failed", hstmt); + print_result_meta(hstmt); + /* + * Print only the 6 first columns, we do not want for example + * to get the OID in output, and this information looks to be + * enough. + */ + print_result_series(hstmt, sql_column_ids, 6); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLColumnPrivileges */ + //printf("Check for SQLColumnPrivileges\n"); + //rc = SQLColumnPrivileges(hstmt, + // NULL, 0, + // (SQLCHAR *) "public", SQL_NTS, + // (SQLCHAR *) "testtab1", SQL_NTS, + // (SQLCHAR *) "id", SQL_NTS); + //CHECK_STMT_RESULT(rc, "SQLColumnPrivileges failed", hstmt); + //print_result_meta(hstmt); + //print_result(hstmt); + //rc = SQLFreeStmt(hstmt, SQL_CLOSE); + //CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLSpecialColumns */ + printf("Check for SQLSpecialColumns\n"); + rc = SQLSpecialColumns(hstmt, SQL_ROWVER, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "testtab1", SQL_NTS, + SQL_SCOPE_SESSION, + SQL_NO_NULLS); + CHECK_STMT_RESULT(rc, "SQLSpecialColumns failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* + * Check for SQLStatistics. It is important to note that this function + * returns statistics like the number of pages used and the number of + * index scans. + */ + printf("Check for SQLStatistics\n"); + rc = SQLStatistics(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "testtab1", SQL_NTS, + 0, 0); + CHECK_STMT_RESULT(rc, "SQLStatistics failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLPrimaryKeys */ + printf("Check for SQLPrimaryKeys\n"); + rc = SQLPrimaryKeys(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "testtab1", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLPrimaryKeys failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLForeignKeys */ + printf("Check for SQLForeignKeys\n"); + rc = SQLForeignKeys(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "testtab1", SQL_NTS, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "testtab_fk", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLForeignKeys failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLProcedures */ + printf("Check for SQLProcedures\n"); + rc = SQLProcedures(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "simple_add", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLProcedures failed", hstmt); + print_result_meta(hstmt); + print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + + /* Check for SQLProcedureColumns */ + printf("Check for SQLProcedureColumns\n"); + rc = SQLProcedureColumns(hstmt, + NULL, 0, + (SQLCHAR *) "public", SQL_NTS, + (SQLCHAR *) "simple_add", SQL_NTS, + NULL, 0); + CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt); + print_result_meta(hstmt); print_result(hstmt); + rc = SQLFreeStmt(hstmt, SQL_CLOSE); + CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); + /* Check for SQLTablePrivileges */ + printf("Check for SQLTablePrivileges\n"); + rc = SQLTablePrivileges(hstmt, + NULL, 0, + (SQLCHAR *) "public", 0, + (SQLCHAR *) "testtab1", SQL_NTS); + CHECK_STMT_RESULT(rc, "SQLTablePrivileges failed", hstmt); + print_result_meta(hstmt); + print_result_series(hstmt, sql_tab_privileges_ids, 6); rc = SQLFreeStmt(hstmt, SQL_CLOSE); CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt); /* + * Extra tests. * Older versions of the driver had a bug in handling table-types lists * longer than 32 entries. Check for that. */ - rc = SQLTables(hstmt, "", SQL_NTS, "public", SQL_NTS, "testtab%", SQL_NTS, diff --git a/test/src/common.c b/test/src/common.c index 962d7d3..091dd1a 100644 --- a/test/src/common.c +++ b/test/src/common.c @@ -163,23 +163,17 @@ const char *nullable_str(SQLSMALLINT nullable) } void -print_result_meta(HSTMT hstmt) +print_result_meta_series(HSTMT hstmt, + SQLSMALLINT *colids, + SQLSMALLINT numcols) { - SQLRETURN rc; - SQLSMALLINT numcols; int i; - rc = SQLNumResultCols(hstmt, &numcols); - if (!SQL_SUCCEEDED(rc)) - { - print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt); - return; - } - printf("Result set metadata:\n"); - for (i = 1; i <= numcols; i++) + for (i = 0; i < numcols; i++) { + SQLRETURN rc; SQLCHAR colname[50]; SQLSMALLINT colnamelen; SQLSMALLINT datatype; @@ -187,7 +181,7 @@ print_result_meta(HSTMT hstmt) SQLSMALLINT decdigits; SQLSMALLINT nullable; - rc = SQLDescribeCol(hstmt, i, + rc = SQLDescribeCol(hstmt, colids[i], colname, sizeof(colname), &colnamelen, &datatype, @@ -206,10 +200,11 @@ print_result_meta(HSTMT hstmt) } void -print_result(HSTMT hstmt) +print_result_meta(HSTMT hstmt) { SQLRETURN rc; - SQLSMALLINT numcols; + SQLSMALLINT numcols, i; + SQLSMALLINT *colids; rc = SQLNumResultCols(hstmt, &numcols); if (!SQL_SUCCEEDED(rc)) @@ -218,6 +213,21 @@ print_result(HSTMT hstmt) return; } + colids = (SQLSMALLINT *) malloc(numcols * sizeof(SQLSMALLINT)); + for (i = 0; i < numcols; i++) + colids[i] = i + 1; + print_result_meta_series(hstmt, colids, numcols); + free(colids); +} + +/* + * Print result only for the selected columns. + */ +void +print_result_series(HSTMT hstmt, SQLSMALLINT *colids, SQLSMALLINT numcols) +{ + SQLRETURN rc; + printf("Result set:\n"); while(1) { @@ -230,9 +240,9 @@ print_result(HSTMT hstmt) int i; SQLLEN ind; - for (i = 1; i <= numcols; i++) + for (i = 0; i < numcols; i++) { - rc = SQLGetData(hstmt,i, SQL_C_CHAR, buf, sizeof(buf), &ind); + rc = SQLGetData(hstmt, colids[i], SQL_C_CHAR, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(rc)) { print_diag("SQLGetData failed", SQL_HANDLE_STMT, hstmt); @@ -240,7 +250,7 @@ print_result(HSTMT hstmt) } if (ind == SQL_NULL_DATA) strcpy(buf, "NULL"); - printf("%s%s", (i > 1) ? "\t" : "", buf); + printf("%s%s", (i > 0) ? "\t" : "", buf); } printf("\n"); } @@ -251,3 +261,27 @@ print_result(HSTMT hstmt) } } } + +/* + * Print result on all the columns + */ +void +print_result(HSTMT hstmt) +{ + SQLRETURN rc; + SQLSMALLINT numcols, i; + SQLSMALLINT *colids; + + rc = SQLNumResultCols(hstmt, &numcols); + if (!SQL_SUCCEEDED(rc)) + { + print_diag("SQLNumResultCols failed", SQL_HANDLE_STMT, hstmt); + return; + } + + colids = (SQLSMALLINT *) malloc(numcols * sizeof(SQLSMALLINT)); + for (i = 0; i < numcols; i++) + colids[i] = i + 1; + print_result_series(hstmt, colids, numcols); + free(colids); +} diff --git a/test/src/common.h b/test/src/common.h index 2feceb9..34ad156 100644 --- a/test/src/common.h +++ b/test/src/common.h @@ -27,6 +27,12 @@ extern void print_diag(char *msg, SQLSMALLINT htype, SQLHANDLE handle); extern void test_connect_ext(char *extraparams); extern void test_connect(void); extern void test_disconnect(void); +extern void print_result_meta_series(HSTMT hstmt, + SQLSMALLINT *colids, + SQLSMALLINT numcols); +extern void print_result_series(HSTMT hstmt, + SQLSMALLINT *colids, + SQLSMALLINT numcols); extern void print_result_meta(HSTMT hstmt); extern void print_result(HSTMT hstmt); extern const char *datatype_str(SQLSMALLINT datatype);
* Re: Regression tests for functions of info.c 2014-03-13 13:52 Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 2014-03-13 14:01 ` Re: Regression tests for functions of info.c Heikki Linnakangas <hlinnakangas@vmware.com> 2014-03-18 13:08 ` Re: Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> @ 2014-03-18 20:28 ` Heikki Linnakangas <hlinnakangas@vmware.com> 0 siblings, 0 replies; 5+ messages in thread From: Heikki Linnakangas @ 2014-03-18 20:28 UTC (permalink / raw) To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc On 03/18/2014 03:08 PM, Michael Paquier wrote: > On Thu, Mar 13, 2014 at 11:01 PM, Heikki Linnakangas > <hlinnakangas@vmware.com> wrote: >> On 03/13/2014 03:52 PM, Michael Paquier wrote: >>> >>> Please find attached a patch adding regression tests for the functions >>> in info.c. The following functions, that use hardcoded column names >>> for their results are checked: >>> - SQLGetTypeInfo >>> - SQLTables >>> - SQLColumns >>> - SQLSpecialColumns >>> - SQLStatistics >>> - SQLPrimaryKeys >>> - SQLForeignKeys >>> - SQLProcedureColumns >>> - SQLTablePrivileges >>> Note that the number of columns used for some of those functions, like >>> SQLGetTypeInfo, has increased since 0x0300, so those regression tests >>> are not compatible with versions of odbc older than 0x0300 and would >>> need an alternative output. >> >> >> Hmm, that's fine as far as it goes, but surely we need to test that they >> actually return correct data, not just the column names? >> >> I envisioned the "catalogfunctions" test case to eventually cover these, >> although at the moment it only tests SQLTables. The ODBC standard calls >> these "catalog functions", per >> http://msdn.microsoft.com/en-us/library/ms711722%28v=vs.85%29.aspx. From >> that list, you're missing SQLColumnPrivileges and SQLProcedures. > OK, I have been working more on this patch and have integrated all the > tests directly in catalogfunctions. I have also extended as well the > functions in common.c to be able to print results for arrays of column > IDs. I found that this became necessary as the current logic is able > to print results only for all the columns, and there are some data > like table OID or user name that we do not want as output in the test > suite. Thanks, pushed. > Also, I think that I have found a bug, or let's say a limitation with > SQLColumnPrivileges, which does not work with unixodbc 2.3.2. I tried > to use this function on LInux and OSX, each time it failed with the > following error: > ! IM001=[unixODBC][Driver Manager]Driver does not support this function > The patch I am attaching has some commented code for the test case of > SQLColumnPrivileges, but I disabled it. > > For example I tried to call it like that but it failed: > rc = SQLColumnPrivileges(hstmt, NULL, 0, > (SQLCHAR *) "public", SQL_NTS, > (SQLCHAR *) "testtab1", SQL_NTS, > (SQLCHAR *) "id", SQL_NTS); > Comments and feedback are welcome. Hmm, it seems that we don't publish the SQLColumnPrivileges function to the driver manager. See PGAPI_GetFunctions30 in odbcapi30.c: > if (ci->drivers.lie) > SQL_FUNC_ESET(pfExists, SQL_API_SQLCOLUMNPRIVILEGES); /* 56 */ So you have to specify the "Lie" configuration option to enable SQLColumnPrivileges. Got to love the name of that option :-). I wonder why. Perhaps because PostgreSQL used to not support per-column permissions, and no-one's gotten around to implement SQLColumnPrivileges properly since they was added to the backend? - Heikki -- Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2014-03-18 20:28 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2014-03-13 13:52 Regression tests for functions of info.c Michael Paquier <michael.paquier@gmail.com> 2014-03-13 14:01 ` Heikki Linnakangas <hlinnakangas@vmware.com> 2014-03-13 14:20 ` Michael Paquier <michael.paquier@gmail.com> 2014-03-18 13:08 ` Michael Paquier <michael.paquier@gmail.com> 2014-03-18 20:28 ` Heikki Linnakangas <hlinnakangas@vmware.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox