List:Commits« Previous MessageNext Message »
From:pharvey Date:June 16 2006 6:00am
Subject:Connector/ODBC 5 commit: r342 - in trunk: MYODBCC/MYODBCCLib MYSQLPlus/MYSQLPlusLib MYSQLPlus/MYSQLPlusTest
View as plain text  
Modified:
   trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MDescriptorIPD.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.h
   trunk/MYSQLPlus/MYSQLPlusLib/MDiagnosticRecord.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
   trunk/MYSQLPlus/MYSQLPlusTest/MYSQLPlusTest.cpp
Log:
Some improvements to the MYSQLPlusTest output including some tweaks to the format of the
diagnostic messages. 

Modified: trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp
===================================================================
--- trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYODBCC/MYODBCCLib/MYODBCC.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -1453,6 +1453,7 @@
     SQLINTEGER  nSrcLenChars    = 0;
     SQLINTEGER *pnSrcLenChars   = pnSrcLenCharsPtr;
 
+// wprintf( TEXT("[PAH][%s][%d] (%s)\n"), TEXT(__FILE__), __LINE__, pszSrc );
     if ( !pnSrcLenCharsPtr )
         pnSrcLenChars = &nSrcLenChars;
 

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MDescriptorIPD.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MDescriptorIPD.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MDescriptorIPD.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -10,7 +10,6 @@
 {
     MYODBCDbgEnter();
 
-printf( "[PAH][%s][%d] field=%d\n", __FILE__, __LINE__, nFieldIdentifier );
     /*!
         \internal ODBC Rule
 

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -255,7 +255,7 @@
     if ( nRecNumber > getNumber() )
         MYODBCDbgReturn( SQL_NO_DATA );
 
-    MYODBCDbgReturn( ((MDiagnosticRecord*)(children()[nRecNumber - 1]))->getDiagRec(
psSqlstate, pnNativeErrorPtr, pszMessageText, nBufferLength, pnTextByteLength ) );
+    MYODBCDbgReturn( ((MDiagnosticRecord*)(children().at( nRecNumber - 1
)))->getDiagRec( psSqlstate, pnNativeErrorPtr, pszMessageText, nBufferLength,
pnTextByteLength ) );
 }
 
 /*!
@@ -366,14 +366,14 @@
 
     SQLWCHAR    sSqlstate[6];
     SQLINTEGER  nNativeError;
-    SQLWCHAR    sMessageText[1024];
+    SQLWCHAR    szMessageText[1024];
     SQLSMALLINT nTextLength;
 
     for ( SQLSMALLINT nRecord = 1; 
-          SQL_SUCCEEDED( getDiagRec( nRecord, sSqlstate, &nNativeError, sMessageText,
sizeof(sMessageText), &nTextLength ) ); 
+          SQL_SUCCEEDED( getDiagRec( nRecord, sSqlstate, &nNativeError,
szMessageText, sizeof(szMessageText), &nTextLength ) ); 
           nRecord++ )
     {
-        stringlist += QString::fromUtf16( sMessageText );
+        stringlist += QString::fromUtf16( szMessageText );
     }
 
     MYODBCDbgReturn3( "%p", stringlist );

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.h
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.h	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MDiagnostic.h	2006-06-16 06:00:42 UTC (rev 342)
@@ -218,7 +218,6 @@
         DIA_IM014,  /* Invalid name of File DSN                                        
*/
         DIA_IM015,  /* Corrupt file data source                                        
*/
         DIA_MAX
-
     };
 
     MDiagnostic( QObject *pObjectParent = NULL );

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MDiagnosticRecord.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MDiagnosticRecord.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MDiagnosticRecord.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -29,6 +29,8 @@
     MYODBCDbgEnter();
 
     Q_ASSERT( !pDiagnostic );
+    Q_ASSERT( nState < 0 );
+    Q_ASSERT( nState >= DIA_MAX );
 
     this->nState        = nState;
     nColumnNumber       = SQL_NO_COLUMN_NUMBER;
@@ -265,48 +267,45 @@
 {
     MYODBCDbgEnter();
 
-    /* this message formated according to odbc spec */
+    /*!
+        \internal ODBC RULE
+
+        If the source of an error or warning is a component itself, the diagnostic
message must explain this. 
+        Therefore, the text of messages has two different formats. For errors and
warnings that do not occur 
+        in a data source, the diagnostic message must use this format:
+
+            [vendor-identifier][ODBC-component-identifier]component-supplied-text
+
+        For errors and warnings that occur in a data source, the diagnostic message must
use this format:
+
+           
[vendor-identifier][ODBC-component-identifier][data-source-identifier]data-source-supplied-text
+
+        \note
+
+        We have a data source (MySQL client lib or MySQL server) generated diagnostic
record when nNative is
+        > 0. If nNative == 0 then we are dealing with a driver generated diagnostic
record.
+    */
+
+    /* server message */
     if ( nNative )
     {
-        /* server message */
-        if ( stringMessage.isEmpty() )
-        {
-            MYODBCDbgReturn3( "%s", (QString( "[%1][%2 %3][%4] %5 %6" )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( MYODBC_NAME )
-                                    .arg( MYODBC_VERSION )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( nNative )
-                                    .arg( MDiagnostic_pStates[nState].stringText )) );
-        }
-        else
-            MYODBCDbgReturn3( "%s", (QString( "[%1][%2 %3][%4] %5 %6" )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( MYODBC_NAME )
-                                    .arg( MYODBC_VERSION )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( nNative )
-                                    .arg( stringMessage )) );
+        MYODBCDbgReturn3( "%s", (QString( "[%1][%2 %3][%4] %5 %6" )
+                                .arg( MYODBC_VENDOR )
+                                .arg( MYODBC_NAME )
+                                .arg( MYODBC_VERSION )
+                                .arg( getServerName() )
+                                .arg( nNative )
+                                .arg( getMessage() )) );
     }
+    /* driver message */
     else
     {
-        /* driver message */
-        if ( stringMessage.isEmpty() )
-        {
-            MYODBCDbgReturn3( "%s", QString( "[%1][%2 %3][%4] %5" )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( MYODBC_NAME )
-                                    .arg( MYODBC_VERSION )
-                                    .arg( MDiagnostic_pStates[nState].stringSQLState )
-                                    .arg( MDiagnostic_pStates[nState].stringText ) );
-        }
-        else
-            MYODBCDbgReturn3( "%s", QString( "[%1][%2 %3][%4] %5" )
-                                    .arg( MYODBC_VENDOR )
-                                    .arg( MYODBC_NAME )
-                                    .arg( MYODBC_VERSION )
-                                    .arg( MDiagnostic_pStates[nState].stringSQLState )
-                                    .arg( stringMessage ) );
+        MYODBCDbgReturn3( "%s", QString( "[%1][%2 %3] %4" )
+                                .arg( MYODBC_VENDOR )
+                                .arg( MYODBC_NAME )
+                                .arg( MYODBC_VERSION )
+//                                    .arg( MDiagnostic_pStates[nState].stringSQLState )
+                                .arg( getMessage() ) );
     }
 
     MYODBCDbgReturn1( stringMessage );
@@ -316,6 +315,15 @@
 {
     MYODBCDbgEnter();
 
+    /*!
+        \internal MYODBC RULE
+
+        The message text is never empty. So if the driver, the client lib, or the server
did not 
+        supply a message we fallback to the standard SQL state message.
+    */
+    if ( stringMessage.isEmpty() )
+        MYODBCDbgReturn1( MDiagnostic_pStates[nState].stringText );
+
     MYODBCDbgReturn1( stringMessage );
 }
 
@@ -337,6 +345,18 @@
 {
     MYODBCDbgEnter();
 
+    /*!
+        \internal MYODBC RULE
+
+        The server name is inherited from the parent MDiagnostic at the time we were
instantiated. 
+        If we were connected to a server we can get the server name and version (as in
"MySQL v5.03"). 
+        But if we were not connected or if we are the diagnostic for something other than
MConnection - 
+        we will have an empty string. The spec says we can use an empty string for this
scenario but we 
+        will return MYODBC_VENDOR ("MySQL"). 
+    */
+    if ( stringServerName.isEmpty() )
+        MYODBCDbgReturn1( MYODBC_VENDOR );
+
     MYODBCDbgReturn1( stringServerName );
 }
 

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -994,7 +994,6 @@
     SQLRETURN   nReturn     = SQL_SUCCESS;
     BOOLEAN     bHasInfo    = false;
 
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     /*!
         \internal
 
@@ -1131,7 +1130,6 @@
         This argument sets the SQL_DESC_TYPE, SQL_DESC_CONCISE_TYPE, and 
         SQL_DESC_DATETIME_INTERVAL_CODE fields of the APD.
     */
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_CONCISE_TYPE,
(SQLPOINTER)(SQLINTEGER)nValueType, SQL_IS_SMALLINT );
     switch ( nReturn )
     {
@@ -1152,7 +1150,6 @@
         argument sets the SQL_DESC_TYPE, SQL_DESC_CONCISE_TYPE, and 
         SQL_DESC_DATETIME_INTERVAL_CODE fields of the IPD.
     */
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     nReturn = pImpParamDesc->setDescField( nParameterNumber, SQL_DESC_CONCISE_TYPE,
(SQLPOINTER)(SQLINTEGER)nParameterType, SQL_IS_SMALLINT );
     switch ( nReturn )
     {
@@ -1179,7 +1176,6 @@
 
         For other data types, the ColumnSize argument is ignored.
     */      
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     switch ( nParameterType )
     {
         case SQL_DECIMAL:
@@ -1246,7 +1242,6 @@
         SQL_DESC_SCALE field of the IPD is set to DecimalDigits. For all other data 
         types, the DecimalDigits argument is ignored.  
     */        
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     switch ( nParameterType )
     {
         case SQL_NUMERIC:
@@ -1292,7 +1287,6 @@
 
         Factor in the ODBC rules found in the spec.
     */      
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_OCTET_LENGTH,
(SQLPOINTER)nBufferLength, SQL_IS_INTEGER );
     switch ( nReturn )
     {
@@ -1371,8 +1365,6 @@
         We want to set this value last, as long as we are using MYODBCDrvSetDescField
         to set the value, because this will cause a deeper validation.
     */       
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
-
     nReturn = pAppParamDesc->setDescField( nParameterNumber, SQL_DESC_DATA_PTR,
pParameterValue, SQL_IS_POINTER );
     switch ( nReturn )
     {
@@ -1385,7 +1377,6 @@
             goto doBindParameterExit1;
     }
 
-printf( "[PAH][%s][%d]\n", __FILE__, __LINE__ );
     if ( bHasInfo )
         nReturn = SQL_SUCCESS_WITH_INFO;
 

Modified: trunk/MYSQLPlus/MYSQLPlusTest/MYSQLPlusTest.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusTest/MYSQLPlusTest.cpp	2006-06-15 23:21:24 UTC (rev 341)
+++ trunk/MYSQLPlus/MYSQLPlusTest/MYSQLPlusTest.cpp	2006-06-16 06:00:42 UTC (rev 342)
@@ -16,6 +16,8 @@
 
 private:
     QFile           fileDebugOut;
+    QFile           fileStdOut;
+    QTextStream     textstreamStdOut;
     MEnvironment    environment;
     MConnection *   pConnection;
 
@@ -42,6 +44,9 @@
     {
         MYODBCDbgInit( stdout );
     }
+
+    fileStdOut.open( stdout, QFile::WriteOnly );
+    textstreamStdOut.setDevice( &fileStdOut );
 }
 
 MYSQLPlusTest::~MYSQLPlusTest()
@@ -110,7 +115,7 @@
 
     SQLRETURN nReturn = statement.doExecDirect( psSQL, SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 }
 
@@ -151,17 +156,17 @@
     nReturn = statement.doExecDirect( TEXT("INSERT INTO tbMyODBCTest ( vcName ) VALUES (
'name1' )"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
         *gpMYODBCDbg << endl << statement.getDiagnostics().join( "\n" )
<< endl;
-//        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+//        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doExecDirect( TEXT("INSERT INTO tbMyODBCTest ( vcName ) VALUES (
'name2' )"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doExecDirect( TEXT("INSERT INTO tbMyODBCTest ( vcName ) VALUES (
'name3' )"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 }
 
@@ -187,23 +192,23 @@
     /* this should error out */
     nReturn = statement.doNumResultCols( &nCols );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().at( 0
).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_ERROR );
 
     nReturn = statement.doExecDirect( TEXT("SELECT * FROM tbMyODBCTest"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doNumResultCols( &nCols );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
     QCOMPARE( nCols, (SQLSMALLINT)3 );
 
     nReturn = statement.doRowCount( &nRows );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
     QCOMPARE( nRows, (SQLINTEGER)3 );
 
@@ -220,7 +225,7 @@
 
         nReturn = statement.getData( 1, SQL_C_LONG, &nUserID, 0, &nStrLenOrInd );
         if ( nReturn != SQL_SUCCESS )
-            std::cout << endl << endl <<
statement.getDiagnostics().join( "\n" ).toAscii().data() << endl << endl;
+            textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
         QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
         QVERIFY( nStrLenOrInd == 0 );
 
@@ -269,17 +274,17 @@
 
     nReturn = statement.doBindParameter( 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 100,
0, szName, 0, &nStrLenOrIndName );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doBindParameter( 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 100,
0, szCreated, 0, &nStrLenOrIndCreated );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doPrepare( TEXT("UPDATE tbMyODBCTest SET dCreated = ? WHERE
vcName = ?"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     strcpy( (char*)szName, "name2" ); 
@@ -287,12 +292,12 @@
 
     nReturn = statement.doExecute();
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nReturn = statement.doRowCount( &nRowCount );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
     QVERIFY( nRowCount == 1 );
 
@@ -301,7 +306,7 @@
 
     nReturn = statement.doExecute();
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 }
 
@@ -319,7 +324,7 @@
 
     nReturn = statement.doExecDirect( TEXT("SELECT * FROM tbMyODBCTest"), SQL_NTS );
     if ( nReturn != SQL_SUCCESS )
-        std::cout << endl << endl << statement.getDiagnostics().join(
"\n" ).toAscii().data() << endl << endl;
+        textstreamStdOut << endl << endl <<
statement.getDiagnostics().join( "\n" ) << endl << endl;
     QCOMPARE( nReturn, (SQLRETURN)SQL_SUCCESS );
 
     nRows = 0;

Thread
Connector/ODBC 5 commit: r342 - in trunk: MYODBCC/MYODBCCLib MYSQLPlus/MYSQLPlusLib MYSQLPlus/MYSQLPlusTestpharvey16 Jun