changeset 86140:f592033933d0

Add test of SQLTables() where table types names are enclosed by single quotes.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 21 Jul 2022 16:36:30 +0200
parents 0da716c863f9
children 429ad7e2d502
files clients/odbc/driver/SQLTables.c clients/odbc/tests/ODBCmetadata.c
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -196,7 +196,10 @@ MNDBTables(ODBCStmt *stmt,
 		}
 
 		if (NameLength4 > 0) {
-			/* filtering requested on table type */
+			/* filtering requested on table type(s)
+			 * each table type can be enclosed in single quotation marks (')
+			 * or unquoted, for example, 'TABLE', 'VIEW' or TABLE, VIEW.
+			 */
 			char buf[32];	/* the longest string is "GLOBAL TEMPORARY TABLE" */
 			int i;
 			size_t j;
--- a/clients/odbc/tests/ODBCmetadata.c
+++ b/clients/odbc/tests/ODBCmetadata.c
@@ -431,7 +431,24 @@ main(int argc, char **argv)
 		"NULL	odbctst	pk2c	TABLE	NULL\n"
 		"NULL	odbctst	pk_uc	TABLE	NULL\n");
 
-	// All user tables and views
+	// All user tables and views in schema odbctst
+	ret = SQLTables(stmt, (SQLCHAR*)"", SQL_NTS,
+			(SQLCHAR*)"odbctst", SQL_NTS, (SQLCHAR*)"%", SQL_NTS,
+			(SQLCHAR*)"'TABLE' , 'VIEW'", SQL_NTS);	// using quotes around the type names
+	compareResult(stmt, ret, "SQLTables (odbctst, %, 'TABLE' , 'VIEW')",
+		"Resultset with 5 columns\n"
+		"Resultset with 7 rows\n"
+		"TABLE_CAT	TABLE_SCHEM	TABLE_NAME	TABLE_TYPE	REMARKS\n"
+		"WVARCHAR(1)	WVARCHAR(1024)	WVARCHAR(1024)	WVARCHAR(25)	WVARCHAR(65000)\n"
+		"NULL	odbctst	CUSTOMERS	TABLE	NULL\n"
+		"NULL	odbctst	LINES	TABLE	NULL\n"
+		"NULL	odbctst	ORDERS	TABLE	NULL\n"
+		"NULL	odbctst	fk2c	TABLE	NULL\n"
+		"NULL	odbctst	nopk_twoucs	TABLE	NULL\n"
+		"NULL	odbctst	pk2c	TABLE	NULL\n"
+		"NULL	odbctst	pk_uc	TABLE	NULL\n");
+
+	// All user tables and views in all schemas
 	ret = SQLTables(stmt, (SQLCHAR*)"", SQL_NTS,
 			(SQLCHAR*)"%", SQL_NTS, (SQLCHAR*)"%", SQL_NTS,
 			(SQLCHAR*)"TABLE, VIEW, GLOBAL TEMPORARY TABLE, LOCAL TEMPORARY TABLE", SQL_NTS);