List:Commits« Previous MessageNext Message »
From:jbalint Date:November 17 2006 9:44am
Subject:Connector/ODBC 5 commit: r681 - in trunk: Driver/Driver/Tests SDK/MYSQLPlus/Library
View as plain text  
Modified:
   trunk/Driver/Driver/Tests/TSTNumericStruct.c
   trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp
   trunk/SDK/MYSQLPlus/Library/MResultPlus.h
Log:
Fixed precision and assertions in numeric struct.
Fixed wildcard handling of and listing of catalogs and tables in SQLTables.

Modified: trunk/Driver/Driver/Tests/TSTNumericStruct.c
===================================================================
--- trunk/Driver/Driver/Tests/TSTNumericStruct.c	2006-11-17 07:39:14 UTC (rev 680)
+++ trunk/Driver/Driver/Tests/TSTNumericStruct.c	2006-11-17 08:44:04 UTC (rev 681)
@@ -67,7 +67,7 @@
     int         nSign = 1;
     long        nScaled;
     long        nDivisor;
-    float       nValue;
+    double      nValue;
     BOOL        bReturn = TRUE;
 
     /* INIT 1 */
@@ -84,7 +84,8 @@
     nReturn = MYODBCTstExecDirect( hStm, _T("SELECT * FROM TSTNumericStruct"), SQL_NTS );
 
     /* INIT 3 */
-    nReturn = SQLBindCol( hStm, 1, SQL_C_NUMERIC, &structNumeric, 19,
&nStrLenOrInd1 );
+    nReturn = SQLBindCol( hStm, 1, SQL_C_NUMERIC, &structNumeric,
+            sizeof(SQL_NUMERIC_STRUCT), &nStrLenOrInd1 );
     nReturn = SQLGetStmtAttr( hStm, SQL_ATTR_APP_ROW_DESC, &hDes, 0, NULL );
     nReturn = SQLSetDescField( hDes, 1, SQL_DESC_TYPE, (VOID*)SQL_C_NUMERIC, 0 );
     nReturn = SQLSetDescField( hDes, 1, SQL_DESC_PRECISION, (VOID*)5, 0 );
@@ -95,28 +96,16 @@
     /* MAIN */
     while ( ( nReturn = MYODBCTstFetch( hStm ) ) != SQL_NO_DATA )
     {
-        nReturn = MYODBCTstGetData( hStm, 1, SQL_ARD_TYPE, &structNumeric, 19,
&nStrLenOrInd2 ); 
+        nReturn = MYODBCTstGetData( hStm, 1, SQL_ARD_TYPE, &structNumeric,
+                sizeof(SQL_NUMERIC_STRUCT), &nStrLenOrInd2 ); 
         if ( SQL_NULL_DATA == nStrLenOrInd2 )
             continue;
 
         nScaled = TSTNumericStruct_toScaled( structNumeric.val );
-
-        nDivisor = 1;
-        if ( structNumeric.scale > 0 )
+        if ( nScaled != 25212 || structNumeric.scale != 3 || structNumeric.sign != 1 )
         {
-            for ( i = 0; i < structNumeric.scale; i++ )
-                nDivisor = nDivisor * 10;
-        }
-        nValue = (float)nScaled / (float)nDivisor;
-
-        if ( !structNumeric.sign )
-            nSign = -1;
-        else
-            nSign = 1;
-
-        nValue *= nSign;
-        if ( nValue != 25.212L )
             bReturn = FALSE;
+        }
     }
 
     /* FINI 1 */

Modified: trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp	2006-11-17 07:39:14 UTC (rev 680)
+++ trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp	2006-11-17 08:44:04 UTC (rev 681)
@@ -807,9 +807,9 @@
         empty strings, the result set contains a list of valid table types for the data
source. 
         (All columns except the TABLE_TYPE column contain NULLs.) 
     */
-    if ( ( stringCatalog.isEmpty() && !stringCatalog.isNull() ) &&
-         ( stringSchema.isEmpty() && !stringSchema.isNull() ) &&
-         ( stringTable.isEmpty() && !stringTable.isNull() ) &&
+    if ( ( stringCatalog.isNull() ) &&
+         ( stringSchema.isNull() ) &&
+         ( stringTable.isNull() ) &&
          stringTableType == SQL_ALL_TABLE_TYPES )
     {
         nReturn = doAppendTablesTableTypes();
@@ -821,9 +821,9 @@
         set contains a list of valid schemas for the data source. (All columns except the
TABLE_SCHEM 
         column contain NULLs.) 
     */
-    else if ( ( stringCatalog.isEmpty() && !stringCatalog.isNull() ) &&
+    else if ( ( stringCatalog.isNull() ) &&
               stringSchema == SQL_ALL_SCHEMAS && 
-              ( stringTable.isEmpty() && !stringTable.isNull() ) )
+              ( stringTable.isNull() ) )
     {
         nReturn = doAppendTablesSchemas();
     }
@@ -835,8 +835,8 @@
         contain NULLs.) 
     */
     else if ( stringCatalog == SQL_ALL_CATALOGS &&
-              ( stringSchema.isEmpty() && !stringSchema.isNull() ) && 
-              ( stringTable.isEmpty() && !stringTable.isNull() )  )
+              ( stringSchema.isNull() ) && 
+              ( stringTable.isNull() )  )
     {
         nReturn = doAppendTablesCatalogs();
     }
@@ -1847,10 +1847,10 @@
         MYODBCDbgReturn( doAppendTablesSchemas( stringCatalog, stringSchemaFilter,
stringTableFilter, stringTableType ) );
     }
 
-    QStringList stringlistCatalogs = filterByWildcard( getCatalogs( "%"),
-            getStatement()->getMetadataID() == SQL_FALSE &&
-                    getEnvironment()->getODBCVersion() != SQL_OV_ODBC2 ?
-                stringCatalogFilter : "%" );
+    QStringList stringlistCatalogs = filterByWildcard( getCatalogs( "%" ),
+    		stringCatalogFilter,
+    		getStatement()->getMetadataID() != SQL_FALSE ||
+				getEnvironment()->getODBCVersion() == SQL_OV_ODBC2 );
 
     for ( int n = 0; n < stringlistCatalogs.count(); n++ )
     {
@@ -1870,9 +1870,8 @@
     SQLRETURN nReturn = SQL_SUCCESS;
 
     QStringList stringlistSchemas = filterByWildcard(
-            getSchemas( stringCatalog, "%"),
-            getStatement()->getMetadataID() == SQL_FALSE ?
-                stringSchemaFilter : "%" );
+            getSchemas( stringCatalog, "%" ), stringSchemaFilter,
+            getStatement()->getMetadataID() != SQL_FALSE );
 
     for ( int n = 0; n < stringlistSchemas.count(); n++ )
     {
@@ -1921,8 +1920,7 @@
 
     QStringList stringlistTables = filterByWildcard(
             getTables( stringCatalog, stringSchema, "%" ),
-            getStatement()->getMetadataID() == SQL_FALSE ?
-                stringTableFilter : "%" );
+			stringTableFilter, getStatement()->getMetadataID() != SQL_FALSE );
 
     for ( int n = 0; n < stringlistTables.count(); n++ )
     {
@@ -1956,10 +1954,10 @@
         MYODBCDbgReturn( doAppendColumnsSchemas( stringCatalog, stringSchemaFilter,
stringTableFilter, stringColumnFilter ) );
     }
 
-    QStringList stringlistCatalogs = filterByWildcard( getCatalogs( "%"),
-            getStatement()->getMetadataID() == SQL_FALSE &&
-                    getEnvironment()->getODBCVersion() != SQL_OV_ODBC2 ?
-                stringSchemaFilter : "%" );
+    QStringList stringlistCatalogs = filterByWildcard( getCatalogs( "%" ),
+                stringSchemaFilter,
+                getStatement()->getMetadataID() != SQL_FALSE ||
+                    getEnvironment()->getODBCVersion() == SQL_OV_ODBC2 );
 
     for ( int n = 0; n < stringlistCatalogs.count(); n++ )
     {
@@ -1979,9 +1977,8 @@
     SQLRETURN nReturn = SQL_SUCCESS;
 
     QStringList stringlistSchemas = filterByWildcard(
-            getSchemas( stringCatalog, "%"),
-            getStatement()->getMetadataID() == SQL_FALSE ?
-                stringSchemaFilter : "%" );
+            getSchemas( stringCatalog, "%" ), stringSchemaFilter,
+            getStatement()->getMetadataID() != SQL_FALSE );
 
     for ( int n = 0; n < stringlistSchemas.count(); n++ )
     {
@@ -2001,9 +1998,8 @@
     SQLRETURN nReturn = SQL_SUCCESS;
 
     QStringList stringlistTables = filterByWildcard(
-            getTables( stringCatalog, stringSchema, "%" ),
-            getStatement()->getMetadataID() == SQL_FALSE ?
-                stringTableFilter : "%" );
+            getTables( stringCatalog, stringSchema, "%" ), stringTableFilter,
+            getStatement()->getMetadataID() != SQL_FALSE );
 
     for ( int n = 0; n < stringlistTables.count(); n++ )
     {
@@ -2636,7 +2632,8 @@
     MYODBCDbgReturn( SQL_SUCCESS );
 }
 
-QStringList MResultPlus::filterByWildcard( QStringList items, QString wildcard)
+QStringList MResultPlus::filterByWildcard( QStringList items, QString wildcard,
+		int wcliteral )
 {
     QStringList result;
     QStringList::const_iterator i;
@@ -2654,6 +2651,10 @@
         /* null wildcard matches all */
         regex.setPattern("*");
     }
+	else if(wcliteral)
+	{
+		regex.setPattern(wildcard);
+	}
     else
     {
         /* fix up the wildcard to a regex, leaving escaped chars alone */

Modified: trunk/SDK/MYSQLPlus/Library/MResultPlus.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultPlus.h	2006-11-17 07:39:14 UTC (rev 680)
+++ trunk/SDK/MYSQLPlus/Library/MResultPlus.h	2006-11-17 08:44:04 UTC (rev 681)
@@ -250,7 +250,8 @@
     /*!
         Filter a list of items by an SQL-style wildcard.
     */
-    QStringList filterByWildcard(QStringList items, QString wildcard);
+    QStringList filterByWildcard(QStringList items, QString wildcard,
+    		int wcliteral);
 };
 
 #endif

Thread
Connector/ODBC 5 commit: r681 - in trunk: Driver/Driver/Tests SDK/MYSQLPlus/Libraryjbalint17 Nov