List:Commits« Previous MessageNext Message »
From:jbalint Date:March 22 2007 2:46am
Subject:ODBC C-tests commit: r43 - trunk/testsuites/t_jbalint
View as plain text  
Modified:
   trunk/testsuites/t_jbalint/basic.c
Log:
add basic test for conn SQL_ATTR_CURRENT_CATALOG

Modified: trunk/testsuites/t_jbalint/basic.c
===================================================================
--- trunk/testsuites/t_jbalint/basic.c	2007-03-19 18:14:22 UTC (rev 42)
+++ trunk/testsuites/t_jbalint/basic.c	2007-03-22 02:46:30 UTC (rev 43)
@@ -32,3 +32,47 @@
 
     free_statement(stmt);
 }
+
+/*
+ * Test the SQL_ATTR_CURRENT_CATALOG connection attribute.
+ *
+ * We test by setting information_schema which is a separate
+ * catalog we know to exist.
+ *
+ * TODO we currently don't support in the driver setting this
+ *      attribute before we're connected, or setting it when
+ *      there is an active statement
+ */
+OT_TEST_METHOD(conn_attr_curr_catalog)
+{
+    SQLHANDLE stmt = get_statement();
+    SQLHANDLE dbc = get_dbc_handle();
+    const char *tstcatalog = "information_schema";
+    SQLCHAR initcatalog[STRLEN];
+    SQLCHAR getcatalog[STRLEN];
+
+    /* get */
+    CHECK_SQL(SQLGetConnectAttr(dbc, SQL_ATTR_CURRENT_CATALOG,
+        initcatalog, STRLEN, NULL), dbc, SQL_HANDLE_DBC);
+
+    test_printf("Current catalog: %s\n", initcatalog);
+
+    /* change */
+    CHECK_SQL(SQLSetConnectAttr(dbc, SQL_ATTR_CURRENT_CATALOG,
+        tstcatalog, SQL_NTS), dbc, SQL_HANDLE_DBC);
+
+    /* verify */
+    CHECK_SQL_S(SQLExecDirect(stmt, "select database()", SQL_NTS), stmt);
+    CHECK_SQL_S(SQLFetch(stmt), stmt);
+    CHECK_SQL_S(SQLGetData(stmt, 1, SQL_C_CHAR,
+        getcatalog, STRLEN, NULL), stmt);
+    test_printf("Now: %s\n", getcatalog);
+    OT_ASSERT_STR_MSG("set catalog took effect", tstcatalog, getcatalog);
+
+    /* free statement so we can set it back */
+    free_statement(stmt);
+
+    /* set it back */
+    CHECK_SQL(SQLSetConnectAttr(dbc, SQL_ATTR_CURRENT_CATALOG,
+        initcatalog, SQL_NTS), dbc, SQL_HANDLE_DBC);
+}
\ No newline at end of file

Thread
ODBC C-tests commit: r43 - trunk/testsuites/t_jbalintjbalint22 Mar