]> git.saurik.com Git - wxWidgets.git/commitdiff
The wxDb::Open() function that takes a wxDbConnectInf() now has a second optional...
authorGeorge Tasker <gtasker@allenbrook.com>
Wed, 12 May 2004 14:10:27 +0000 (14:10 +0000)
committerGeorge Tasker <gtasker@allenbrook.com>
Wed, 12 May 2004 14:10:27 +0000 (14:10 +0000)
wxDb::getDbInfo() function will now not treat SQL_SUCCESS_WITH_INFO as a failure when checking for supported features.
Reformatting of some text, and removal of old commented out code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27228 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/db.cpp

index 510800250a41633000cff6a7276a7cc5f68fc54b..cb2fb2e9aff7402e3db7ac973f14a8eae9c3c21b 100644 (file)
@@ -757,7 +757,6 @@ bool wxDb::Open(const wxString &Dsn, const wxString &Uid, const wxString &AuthSt
     else
         typeInfBlob.FsqlType = SQL_LONGVARBINARY;
 
-//typeInfBlob.TypeName = "BLOB";
 
 #ifdef DBDEBUG_CONSOLE
     cout << wxT("VARCHAR DATA TYPE: ") << typeInfVarchar.TypeName << endl;
@@ -774,10 +773,10 @@ bool wxDb::Open(const wxString &Dsn, const wxString &Uid, const wxString &AuthSt
 } // wxDb::Open()
 
 
-bool wxDb::Open(wxDbConnectInf *dbConnectInf)
+bool wxDb::Open(wxDbConnectInf *dbConnectInf, bool failOnDataTypeUnsupported)
 {
     return Open(dbConnectInf->GetDsn(), dbConnectInf->GetUserID(),
-                dbConnectInf->GetPassword());
+                dbConnectInf->GetPassword(), failOnDataTypeUnsupported);
 }  // wxDb::Open()
 
 
@@ -989,21 +988,24 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
     SWORD cb;
     RETCODE retcode;
 
-    if (SQLGetInfo(hdbc, SQL_SERVER_NAME, (UCHAR*) dbInf.serverName, 80, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_SERVER_NAME, (UCHAR*) dbInf.serverName, 80, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DATABASE_NAME, (UCHAR*) dbInf.databaseName, 128, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_DATABASE_NAME, (UCHAR*) dbInf.databaseName, 128, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR*) dbInf.dbmsName, 40, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_DBMS_NAME, (UCHAR*) dbInf.dbmsName, 40, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
@@ -1014,7 +1016,6 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
     // After upgrading to MSVC6, the original 20 char buffer below was insufficient,
     // causing database connectivity to fail in some cases.
     retcode = SQLGetInfo(hdbc, SQL_DBMS_VER, (UCHAR*) dbInf.dbmsVer, 64, &cb);
-
     if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
@@ -1022,28 +1023,32 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ACTIVE_CONNECTIONS, (UCHAR*) &dbInf.maxConnections, sizeof(dbInf.maxConnections), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ACTIVE_CONNECTIONS, (UCHAR*) &dbInf.maxConnections, sizeof(dbInf.maxConnections), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ACTIVE_STATEMENTS, (UCHAR*) &dbInf.maxStmts, sizeof(dbInf.maxStmts), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ACTIVE_STATEMENTS, (UCHAR*) &dbInf.maxStmts, sizeof(dbInf.maxStmts), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DRIVER_NAME, (UCHAR*) dbInf.driverName, 40, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_DRIVER_NAME, (UCHAR*) dbInf.driverName, 40, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DRIVER_ODBC_VER, (UCHAR*) dbInf.odbcVer, 60, &cb) == SQL_ERROR)
+    retcode = SQLGetInfo(hdbc, SQL_DRIVER_ODBC_VER, (UCHAR*) dbInf.odbcVer, 60, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
@@ -1058,21 +1063,24 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DRIVER_VER, (UCHAR*) dbInf.driverVer, 60, &cb) == SQL_ERROR)
+    retcode = SQLGetInfo(hdbc, SQL_DRIVER_VER, (UCHAR*) dbInf.driverVer, 60, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ODBC_API_CONFORMANCE, (UCHAR*) &dbInf.apiConfLvl, sizeof(dbInf.apiConfLvl), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ODBC_API_CONFORMANCE, (UCHAR*) &dbInf.apiConfLvl, sizeof(dbInf.apiConfLvl), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ODBC_SAG_CLI_CONFORMANCE, (UCHAR*) &dbInf.cliConfLvl, sizeof(dbInf.cliConfLvl), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ODBC_SAG_CLI_CONFORMANCE, (UCHAR*) &dbInf.cliConfLvl, sizeof(dbInf.cliConfLvl), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
     {
         // Not all drivers support this call - Nick Gorham(unixODBC)
         dbInf.cliConfLvl = 0;
@@ -1081,14 +1089,16 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
     }
 
-    if (SQLGetInfo(hdbc, SQL_ODBC_SQL_CONFORMANCE, (UCHAR*) &dbInf.sqlConfLvl, sizeof(dbInf.sqlConfLvl), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ODBC_SQL_CONFORMANCE, (UCHAR*) &dbInf.sqlConfLvl, sizeof(dbInf.sqlConfLvl), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_OUTER_JOINS, (UCHAR*) dbInf.outerJoins, 2, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_OUTER_JOINS, (UCHAR*) dbInf.outerJoins, 2, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                // TODO: BugTracker# 785080 : fails with mysql 4 on linux - edr
                // TODO: dbInf.outerJoins[0]='N';
@@ -1099,7 +1109,8 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_PROCEDURES, (UCHAR*) dbInf.procedureSupport, 2, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_PROCEDURES, (UCHAR*) dbInf.procedureSupport, 2, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                // TODO: BugTracker# 785080 : fails with mysql 4 on linux - edr
                // TODO: dbInf.procedureSupport[0]='N';
@@ -1110,7 +1121,8 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ACCESSIBLE_TABLES, (UCHAR*) dbInf.accessibleTables, 2, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ACCESSIBLE_TABLES, (UCHAR*) dbInf.accessibleTables, 2, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                // TODO: BugTracker# 785080 : fails with mysql 4 on linux - edr
                // TODO: dbInf.accessibleTables[0]='N';
@@ -1121,28 +1133,32 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_CURSOR_COMMIT_BEHAVIOR, (UCHAR*) &dbInf.cursorCommitBehavior, sizeof(dbInf.cursorCommitBehavior), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_CURSOR_COMMIT_BEHAVIOR, (UCHAR*) &dbInf.cursorCommitBehavior, sizeof(dbInf.cursorCommitBehavior), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_CURSOR_ROLLBACK_BEHAVIOR, (UCHAR*) &dbInf.cursorRollbackBehavior, sizeof(dbInf.cursorRollbackBehavior), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_CURSOR_ROLLBACK_BEHAVIOR, (UCHAR*) &dbInf.cursorRollbackBehavior, sizeof(dbInf.cursorRollbackBehavior), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_NON_NULLABLE_COLUMNS, (UCHAR*) &dbInf.supportNotNullClause, sizeof(dbInf.supportNotNullClause), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_NON_NULLABLE_COLUMNS, (UCHAR*) &dbInf.supportNotNullClause, sizeof(dbInf.supportNotNullClause), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_ODBC_SQL_OPT_IEF, (UCHAR*) dbInf.supportIEF, 2, &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_ODBC_SQL_OPT_IEF, (UCHAR*) dbInf.supportIEF, 2, &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                // TODO: BugTracker# 785080 : fails with mysql 4 on linux - edr
                // TODO: dbInf.supportIEF[0]='N';
@@ -1153,77 +1169,88 @@ bool wxDb::getDbInfo(bool failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_DEFAULT_TXN_ISOLATION, (UCHAR*) &dbInf.txnIsolation, sizeof(dbInf.txnIsolation), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_DEFAULT_TXN_ISOLATION, (UCHAR*) &dbInf.txnIsolation, sizeof(dbInf.txnIsolation), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_TXN_ISOLATION_OPTION, (UCHAR*) &dbInf.txnIsolationOptions, sizeof(dbInf.txnIsolationOptions), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_TXN_ISOLATION_OPTION, (UCHAR*) &dbInf.txnIsolationOptions, sizeof(dbInf.txnIsolationOptions), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_FETCH_DIRECTION, (UCHAR*) &dbInf.fetchDirections, sizeof(dbInf.fetchDirections), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_FETCH_DIRECTION, (UCHAR*) &dbInf.fetchDirections, sizeof(dbInf.fetchDirections), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_LOCK_TYPES, (UCHAR*) &dbInf.lockTypes, sizeof(dbInf.lockTypes), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_LOCK_TYPES, (UCHAR*) &dbInf.lockTypes, sizeof(dbInf.lockTypes), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_POS_OPERATIONS, (UCHAR*) &dbInf.posOperations, sizeof(dbInf.posOperations), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_POS_OPERATIONS, (UCHAR*) &dbInf.posOperations, sizeof(dbInf.posOperations), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_POSITIONED_STATEMENTS, (UCHAR*) &dbInf.posStmts, sizeof(dbInf.posStmts), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_POSITIONED_STATEMENTS, (UCHAR*) &dbInf.posStmts, sizeof(dbInf.posStmts), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_SCROLL_CONCURRENCY, (UCHAR*) &dbInf.scrollConcurrency, sizeof(dbInf.scrollConcurrency), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_SCROLL_CONCURRENCY, (UCHAR*) &dbInf.scrollConcurrency, sizeof(dbInf.scrollConcurrency), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_SCROLL_OPTIONS, (UCHAR*) &dbInf.scrollOptions, sizeof(dbInf.scrollOptions), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_SCROLL_OPTIONS, (UCHAR*) &dbInf.scrollOptions, sizeof(dbInf.scrollOptions), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_STATIC_SENSITIVITY, (UCHAR*) &dbInf.staticSensitivity, sizeof(dbInf.staticSensitivity), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_STATIC_SENSITIVITY, (UCHAR*) &dbInf.staticSensitivity, sizeof(dbInf.staticSensitivity), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_TXN_CAPABLE, (UCHAR*) &dbInf.txnCapable, sizeof(dbInf.txnCapable), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_TXN_CAPABLE, (UCHAR*) &dbInf.txnCapable, sizeof(dbInf.txnCapable), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
                        return FALSE;
        }
 
-    if (SQLGetInfo(hdbc, SQL_LOGIN_TIMEOUT, (UCHAR*) &dbInf.loginTimeout, sizeof(dbInf.loginTimeout), &cb) != SQL_SUCCESS)
+    retcode = SQLGetInfo(hdbc, SQL_LOGIN_TIMEOUT, (UCHAR*) &dbInf.loginTimeout, sizeof(dbInf.loginTimeout), &cb);
+    if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO )
        {
                DispAllErrors(henv, hdbc);
                if (failOnDataTypeUnsupported)
@@ -1558,8 +1585,8 @@ void wxDb::Close(void)
         if (tiu->pDb == this)
         {
             s.Printf(wxT("(%-20s)     tableID:[%6lu]     pDb:[%p]"), tiu->tableName,tiu->tableID,tiu->pDb);
-            s2.Printf(wxT("Orphaned found using pDb:[%p]"),this);
-            wxLogDebug (s.c_str(),s2.c_str());
+            s2.Printf(wxT("Orphaned table found using pDb:[%p]"),this);
+            wxLogDebug(s.c_str(),s2.c_str());
         }
         pNode = pNode->GetNext();
     }