List:Commits« Previous MessageNext Message »
From:jbalint Date:October 4 2007 4:43pm
Subject:Connector/ODBC 3.51 commit: r804 - in branches/guffert: . driver test
View as plain text  
Modified:
   branches/guffert/ChangeLog
   branches/guffert/driver/ansi.c
   branches/guffert/driver/unicode.c
   branches/guffert/test/my_error.c
   branches/guffert/test/odbctap.h
Log:
fixed diagnostics clearing on dbc/env handles + added test
cleaned-up "expect_*" macros in odbctap.h

Modified: branches/guffert/ChangeLog
===================================================================
--- branches/guffert/ChangeLog	2007-10-04 00:12:51 UTC (rev 803)
+++ branches/guffert/ChangeLog	2007-10-04 16:43:12 UTC (rev 804)
@@ -32,6 +32,7 @@
 
   Bugs fixed:
   * SQL Statements limited to 64k. (Bug #30983)
+  * Diagnostics were not correctly cleared on dbc/env handles.
 
 ----
 

Modified: branches/guffert/driver/ansi.c
===================================================================
--- branches/guffert/driver/ansi.c	2007-10-04 00:12:51 UTC (rev 803)
+++ branches/guffert/driver/ansi.c	2007-10-04 16:43:12 UTC (rev 804)
@@ -423,14 +423,14 @@
     rc= SQLGetDiagRecImpl(SQL_HANDLE_DBC, hdbc, 1, sqlstate, native_error,
                           message, message_max, message_len);
     if (rc == SQL_SUCCESS)
-      CLEAR_DBC_ERROR(hstmt);
+      CLEAR_DBC_ERROR(hdbc);
   }
   else if (henv)
   {
     rc= SQLGetDiagRecImpl(SQL_HANDLE_ENV, henv, 1, sqlstate, native_error,
                           message, message_max, message_len);
     if (rc == SQL_SUCCESS)
-      CLEAR_ENV_ERROR(hstmt);
+      CLEAR_ENV_ERROR(henv);
   }
 
   return rc;

Modified: branches/guffert/driver/unicode.c
===================================================================
--- branches/guffert/driver/unicode.c	2007-10-04 00:12:51 UTC (rev 803)
+++ branches/guffert/driver/unicode.c	2007-10-04 16:43:12 UTC (rev 804)
@@ -310,14 +310,14 @@
     rc= SQLGetDiagRecWImpl(SQL_HANDLE_DBC, hdbc, 1, sqlstate, native_error,
                            message, message_max, message_len);
     if (rc == SQL_SUCCESS)
-      CLEAR_DBC_ERROR(hstmt);
+      CLEAR_DBC_ERROR(hdbc);
   }
   else if (henv)
   {
     rc= SQLGetDiagRecWImpl(SQL_HANDLE_ENV, henv, 1, sqlstate, native_error,
                            message, message_max, message_len);
     if (rc == SQL_SUCCESS)
-      CLEAR_ENV_ERROR(hstmt);
+      CLEAR_ENV_ERROR(henv);
   }
 
   return rc;

Modified: branches/guffert/test/my_error.c
===================================================================
--- branches/guffert/test/my_error.c	2007-10-04 00:12:51 UTC (rev 803)
+++ branches/guffert/test/my_error.c	2007-10-04 16:43:12 UTC (rev 804)
@@ -351,6 +351,38 @@
 }
 
 
+/*
+   Handle-specific tests for env and dbc diagnostics
+*/
+DECLARE_TEST(t_handle_err)
+{
+  SQLHANDLE henv1, hdbc1;
+
+  ok_env(henv1, SQLAllocHandle(SQL_HANDLE_ENV, NULL, &henv1));
+  ok_env(henv1, SQLSetEnvAttr(henv1, SQL_ATTR_ODBC_VERSION,
+                              (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER));
+  ok_env(henv1, SQLAllocHandle(SQL_HANDLE_DBC, henv1, &hdbc1));
+
+  /* we have to connect for the DM to pass the calls to the driver */
+  ok_con(hdbc1, SQLConnect(hdbc1, mydsn, SQL_NTS, myuid, SQL_NTS,
+                           mypwd, SQL_NTS));
+
+  expect_env(henv1, SQLSetEnvAttr(henv1, 999, (SQLPOINTER)1, 0), SQL_ERROR);
+  is(check_sqlstate_ex(henv1, SQL_HANDLE_ENV, "HY010") == OK);
+
+  expect_dbc(hdbc1, SQLSetConnectAttr(hdbc1, SQL_ATTR_ASYNC_ENABLE,
+                                      (SQLPOINTER)SQL_ASYNC_ENABLE_ON,
+                                      SQL_IS_INTEGER), SQL_SUCCESS_WITH_INFO);
+  is(check_sqlstate_ex(hdbc1, SQL_HANDLE_DBC, "01S02") == OK);
+
+  ok_con(hdbc1, SQLDisconnect(hdbc1));
+  ok_con(hdbc1, SQLFreeHandle(SQL_HANDLE_DBC, hdbc1));
+  ok_env(henv1, SQLFreeHandle(SQL_HANDLE_ENV, henv1));
+
+  return OK;
+}
+
+
 BEGIN_TESTS
 #ifndef NO_DRIVERMANAGER
   ADD_TEST(t_odbc2_error)
@@ -366,6 +398,7 @@
   ADD_TEST(bind_notenoughparam1)
   ADD_TEST(bind_notenoughparam2)
   ADD_TEST(getdata_need_nullind)
+  ADD_TEST(t_handle_err)
 END_TESTS
 
 RUN_TESTS

Modified: branches/guffert/test/odbctap.h
===================================================================
--- branches/guffert/test/odbctap.h	2007-10-04 00:12:51 UTC (rev 803)
+++ branches/guffert/test/odbctap.h	2007-10-04 16:43:12 UTC (rev 804)
@@ -320,18 +320,19 @@
 
 /**
   Verify that the result of an ODBC function call matches an expected
-  result, such as SQL_NO_DATA_FOUND.
+  result, such as SQL_ERROR or SQL_NO_DATA_FOUND.
 
-  @param statement Handle for statement object
+  @param hnd       Handle for object
+  @param type      Type of handle
   @param call      The function call
   @param expect    The expected result
 */
-#define expect_stmt(statement, call, expect) \
+#define expect_odbc(hnd, type, call, expect) \
 do { \
   SQLRETURN rc= (call); \
   if (rc != (expect)) \
   { \
-    print_diag(rc, SQL_HANDLE_STMT, (statement), #call, __FILE__, __LINE__); \
+    print_diag(rc, (type), (hnd), #call, __FILE__, __LINE__); \
     printf("# Expected %d, but got %d in %s on line %d\n", (expect), rc, \
            __FILE__, __LINE__); \
     return FAIL; \
@@ -339,25 +340,20 @@
 } while (0)
 
 
-/**
-  Verify that the result of an ODBC function call matches an expected
-  result, such as SQL_ERROR.
+#define expect_env(env, call, expect) \
+  expect_odbc((env), SQL_HANDLE_STMT, (call), (expect))
 
-  @param desc   Handle for descriptor object
-  @param call   The function call
-  @param expect The expected result
-*/
+
+#define expect_dbc(dbc, call, expect) \
+  expect_odbc((dbc), SQL_HANDLE_STMT, (call), (expect))
+
+
+#define expect_stmt(statement, call, expect) \
+  expect_odbc((statement), SQL_HANDLE_STMT, (call), (expect))
+
+
 #define expect_desc(desc, call, expect) \
-do { \
-  SQLRETURN rc= (call); \
-  if (rc != (expect)) \
-  { \
-    print_diag(rc, SQL_HANDLE_DESC, (desc), #call, __FILE__, __LINE__); \
-    printf("# Expected %d, but got %d in %s on line %d\n", (expect), rc, \
-           __FILE__, __LINE__); \
-    return FAIL; \
-  } \
-} while (0)
+  expect_odbc((desc), SQL_HANDLE_DESC, (call), (expect))
 
 
 /**

Thread
Connector/ODBC 3.51 commit: r804 - in branches/guffert: . driver testjbalint4 Oct