List:Commits« Previous MessageNext Message »
From:jwinstead Date:August 1 2007 10:28pm
Subject:Connector/ODBC 3.51 commit: r623 - in trunk: driver test
View as plain text  
Modified:
   trunk/driver/connect.c
   trunk/driver/myutil.h
   trunk/driver/options.c
   trunk/test/my_info.c
   trunk/test/my_tran.c
Log:
Add is_connected() macro for testing whether a DBC is actually connected,
and use it where appropriate.


Modified: trunk/driver/connect.c
===================================================================
--- trunk/driver/connect.c	2007-07-31 23:52:14 UTC (rev 622)
+++ trunk/driver/connect.c	2007-08-01 20:28:15 UTC (rev 623)
@@ -301,7 +301,7 @@
 #else
 
   /* Can't connect if we're already connected. */
-  if (mysql->net.vio != 0)
+  if (is_connected(dbc))
     return set_conn_error(hdbc, MYERR_08002, NULL, 0);
 
   /* Reset error state */

Modified: trunk/driver/myutil.h
===================================================================
--- trunk/driver/myutil.h	2007-07-31 23:52:14 UTC (rev 622)
+++ trunk/driver/myutil.h	2007-08-01 20:28:15 UTC (rev 623)
@@ -40,6 +40,7 @@
 #define if_dynamic_cursor(st) ((st)->stmt_options.cursor_type == SQL_CURSOR_DYNAMIC)
 #define if_forward_cache(st) ((st)->stmt_options.cursor_type ==
SQL_CURSOR_FORWARD_ONLY && \
 			     (st)->dbc->flag & FLAG_NO_CACHE )
+#define is_connected(dbc)    ((dbc)->mysql.net.vio)
 #define trans_supported(db) ((db)->mysql.server_capabilities &
CLIENT_TRANSACTIONS)
 #define autocommit_on(db) ((db)->mysql.server_status & SERVER_STATUS_AUTOCOMMIT)
 #define true_dynamic(flag) (!(flag &FLAG_FORWARD_CURSOR ) && (flag &
FLAG_DYNAMIC_CURSOR))

Modified: trunk/driver/options.c
===================================================================
--- trunk/driver/options.c	2007-07-31 23:52:14 UTC (rev 622)
+++ trunk/driver/options.c	2007-08-01 20:28:15 UTC (rev 623)
@@ -276,7 +276,7 @@
         case SQL_ATTR_AUTOCOMMIT:
             if (ValuePtr != (SQLPOINTER) SQL_AUTOCOMMIT_ON)
             {
-                if (!dbc->server) /* no connection yet */
+                if (!is_connected(dbc))
                 {
                     dbc->commit_flag= CHECK_AUTOCOMMIT_OFF;
                     return SQL_SUCCESS;
@@ -288,7 +288,7 @@
                 if (autocommit_on(dbc))
                     return odbc_stmt(dbc,"SET AUTOCOMMIT=0");
             }
-            else if (!dbc->server) /* no connection yet */
+            else if (!is_connected(dbc))
             {
                 dbc->commit_flag= CHECK_AUTOCOMMIT_ON;
                 return SQL_SUCCESS;
@@ -300,7 +300,7 @@
         case SQL_ATTR_LOGIN_TIMEOUT:
             {
                 /* we can't change timeout values in post connect state */
-               if (dbc->server) {
+               if (is_connected(dbc)) {
                   return set_conn_error(dbc, MYERR_S1011, NULL, 0);
                }
                else
@@ -335,7 +335,7 @@
                     return set_conn_error(hdbc,MYERR_S1009,NULL, 0);
 
                 pthread_mutex_lock(&dbc->lock);
-                if ( dbc->mysql.net.vio )
+                if (is_connected(dbc))
                 {
                     if (mysql_select_db(&dbc->mysql,(char*) db))
                     {
@@ -373,7 +373,7 @@
             break;
 
         case SQL_ATTR_TXN_ISOLATION:
-            if (!dbc->server)  /* no connection yet */
+            if (!is_connected(dbc))  /* no connection yet */
             {
                 dbc->txn_isolation= (SQLINTEGER)ValuePtr;
                 return SQL_SUCCESS;
@@ -518,7 +518,7 @@
                 Unless we're not connected yet, then we just assume it will
                 be REPEATABLE READ, which is the server default.
               */
-              if (!dbc->server)
+              if (!is_connected(dbc))
               {
                 *((SQLINTEGER *) ValuePtr)= SQL_TRANSACTION_REPEATABLE_READ;
                 break;

Modified: trunk/test/my_info.c
===================================================================
--- trunk/test/my_info.c	2007-07-31 23:52:14 UTC (rev 622)
+++ trunk/test/my_info.c	2007-08-01 20:28:15 UTC (rev 623)
@@ -137,7 +137,7 @@
 
   ok_stmt(hstmt, SQLGetTypeInfo(hstmt, SQL_DATETIME));
 
-  is(myrowcount(hstmt) > 1);
+  is(myresult(hstmt) > 1);
 
   ok_stmt(hstmt, SQLFreeStmt(hstmt, SQL_CLOSE));
 

Modified: trunk/test/my_tran.c
===================================================================
--- trunk/test/my_tran.c	2007-07-31 23:52:14 UTC (rev 622)
+++ trunk/test/my_tran.c	2007-08-01 20:28:15 UTC (rev 623)
@@ -27,16 +27,9 @@
 */
 DECLARE_TEST(my_transaction)
 {
-  SQLHDBC hdbc2;
-  SQLHSTMT hstmt2;
-  SQLHENV henv2;
-
-  /** @todo need a mechanism for outputting skip results */
   if (!server_supports_trans(hdbc))
-    return FAIL;
+    skip("Server does not support transactions.");
 
-  alloc_basic_handles(&henv2, &hdbc2, &hstmt2);
-
   /* set AUTOCOMMIT to OFF */
   ok_con(hdbc, SQLSetConnectAttr(hdbc,SQL_ATTR_AUTOCOMMIT,
                                  (SQLPOINTER)SQL_AUTOCOMMIT_OFF,0));
@@ -86,28 +79,26 @@
   ok_con(hdbc, SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT));
 
   /* test the results now, select should not find any data */
-  ok_sql(hstmt2,"SELECT * FROM t1 WHERE col1 = 30");
-  expect_stmt(hstmt2, SQLFetch(hstmt2), SQL_NO_DATA_FOUND);
+  ok_sql(hstmt,"SELECT * FROM t1 WHERE col1 = 30");
+  expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
 
-  ok_stmt(hstmt2, SQLFreeStmt(hstmt2,SQL_CLOSE));
+  ok_stmt(hstmt, SQLFreeStmt(hstmt,SQL_CLOSE));
 
   /* Delete a row to check, and commit the transaction using ENV handler */
   ok_sql(hstmt,"DELETE FROM t1 WHERE col1 = 40");
   ok_con(hdbc, SQLEndTran(SQL_HANDLE_ENV, henv, SQL_COMMIT));
 
   /* test the results now, select should not find any data */
-  ok_sql(hstmt2,"SELECT * FROM t1 WHERE col1 = 40");
-  expect_stmt(hstmt2, SQLFetch(hstmt2), SQL_NO_DATA_FOUND);
+  ok_sql(hstmt,"SELECT * FROM t1 WHERE col1 = 40");
+  expect_stmt(hstmt, SQLFetch(hstmt), SQL_NO_DATA_FOUND);
 
-  ok_stmt(hstmt2, SQLFreeStmt(hstmt2,SQL_CLOSE));
+  ok_stmt(hstmt, SQLFreeStmt(hstmt,SQL_CLOSE));
 
   /* drop the table */
   ok_sql(hstmt,"DROP TABLE t1");
 
   ok_stmt(hstmt, SQLFreeStmt(hstmt,SQL_CLOSE));
 
-  free_basic_handles(&henv2,&hdbc2,&hstmt2);
-
   return OK;
 }
 
@@ -152,6 +143,9 @@
   SQLINTEGER isolation;
   SQLCHAR    tx_isolation[20];
 
+  if (!server_supports_trans(hdbc))
+    skip("Server does not support transactions.");
+
   /* Check that the default is REPEATABLE READ. */
   ok_con(hdbc, SQLGetConnectAttr(hdbc, SQL_ATTR_TXN_ISOLATION, &isolation,
                                  SQL_IS_POINTER, NULL));

Thread
Connector/ODBC 3.51 commit: r623 - in trunk: driver testjwinstead1 Aug