List:Commits« Previous MessageNext Message »
From:pharvey Date:July 12 2006 2:57am
Subject:Connector/ODBC 5 commit: r438 - in trunk/MYSQLPlus: MYSQLPlusLib include
View as plain text  
Modified:
   trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MCommand.h
   trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
   trunk/MYSQLPlus/include/MStatement.h
Log:
work to integrate MCommands/MCommand into preexisting source

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp	2006-07-12 02:57:48 UTC (rev 438)
@@ -34,6 +34,17 @@
     MYODBCDbgReturn2();
 }
 
+MCommand::MCommand()
+{
+    MYODBCDbgEnter();
+
+    pConnection     = NULL;
+    pStatement      = NULL;
+    nCommandType    = COMMAND_TYPE_NULL;
+
+    MYODBCDbgReturn2();
+}
+
 /*!
     \brief      Causes the given command to be prepared.
 
@@ -103,7 +114,7 @@
             /* mismatched quote */
             if ( ( !cQuote.isNull() && cChar != cQuote ) ||                 /*
last char is not going to close our quote            */
                  ( cQuote.isNull() && stringQuotes.contains( cChar ) )  )   /*
last char is going to open a quote                   */
-                MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( tr("mismatched quote near: ") ).arg( stringCommand ) ) );
+                MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "mismatched quote near: " ).arg( stringCommand ) ) );
 
             /* mismatched brace */
             if ( bBraceCheck &&
@@ -111,7 +122,7 @@
                  (nBraceNest == 0 && cChar == cBraceOpen || cChar == cBraceClose)
||
                  nBraceNest > 1 ||
                  nBraceNest < 0 )
-                MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( tr("mismatched brace near: ") ).arg( stringCommand ) ) );
+                MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "mismatched brace near: " ).arg( stringCommand ) ) );
         }
 
         /* brace opening (not in quotes) */

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommand.h
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommand.h	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommand.h	2006-07-12 02:57:48 UTC (rev 438)
@@ -30,7 +30,7 @@
 
     \sa     MCommands
 */
-class MCommand : public QObject
+class MCommand
 {
 public:
     enum COMMAND_TYPE
@@ -51,6 +51,7 @@
 
     MCommand( MConnection *pConnection );
     MCommand( MStatement *pStatement );
+    MCommand();
 
     /* setters */
     SQLRETURN setCommand( const QString &stringCommand );   // this can include ODBC
and/or server specific syntax

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp	2006-07-12 02:57:48 UTC (rev 438)
@@ -152,8 +152,6 @@
 {
     MYODBCDbgEnter();
 
-    SQLRETURN   nReturn = SQL_SUCCESS;
-    SQLRETURN   n;
     QString     stringCommand;
 
     for ( int i = 0; i < size(); ++i ) 
@@ -186,18 +184,20 @@
     /* for each command */
     for ( int nCommand = 0; nCommand < size(); ++nCommand ) 
     {
-        QList<int> listMarkers = at( nCommand ).getParameterMarkers();
+        MCommand c = at( nCommand );
 
+        QList<int> listMarkers = c.getParameterMarkers();
+
         /* for each parameter marker */
         for ( int nMarker = 0; nMarker < listMarkers.size(); ++nMarker ) 
         {
             listParameterMarkers.append( listMarkers.at( nMarker ) + nOffset ); 
         }
 
-        nOffset += at( nCommand ).getCommandNative().length() + 1; // +1 for ';' which is
added by MCommands::getCommandsNative()
+        nOffset += c.getCommandNative().length() + 1; // +1 for ';' which is added by
MCommands::getCommandsNative()
     }
 
-    MYODBCDbgReturn3( "%d", true );
+    MYODBCDbgReturn3( "%p", listParameterMarkers );
 }
 
 /*!

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp	2006-07-12 02:57:48 UTC (rev 438)
@@ -2119,18 +2119,31 @@
     if ( !isConnected() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_08003 ) );
 
+    /* get the statement text into a QString */
     QString     stringText;
-    SQLINTEGER  nCharsOut       = 0;
-    SQLINTEGER  nCharsMaxOut    = nBufferLength / sizeof(SQLWCHAR);
-    BOOLEAN     bTruncated      = false;
 
     if ( nBufferLength == SQL_NTS )
         stringText = QString::fromUtf16( psInStatementText );
     else
         stringText = QString::fromUtf16( psInStatementText, nTextLength1 );
 
-    /* add more value here as time permits */
+    /*!
+        \internal
+        \note
 
+        We use MCommands to do any translation required to get a server friendly
statement.
+    */
+    MCommands commands( this );
+    SQLRETURN nReturn = commands.setCommand( stringText );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        MYODBCDbgReturn( nReturn );
+    stringText = commands.getCommandsNative();
+
+    /* return the server friendly version of the statement text */
+    SQLINTEGER  nCharsOut       = 0;
+    SQLINTEGER  nCharsMaxOut    = nBufferLength / sizeof(SQLWCHAR);
+    BOOLEAN     bTruncated      = false;
+
     bTruncated = !MYODBCC::doStringCopyOut( psOutStatementText, nCharsMaxOut,
(SQLWCHAR*)stringText.utf16(), &nCharsOut );
 
     if ( pnTextLength2 )
@@ -2142,7 +2155,7 @@
         MYODBCDbgReturn( SQL_SUCCESS_WITH_INFO );
     }
 
-    MYODBCDbgReturn( SQL_SUCCESS );
+    MYODBCDbgReturn( nReturn );
 }
 
 /*!
@@ -4589,12 +4602,12 @@
     */
     if ( !pMySQL )
     {
-        getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("No mysql handle yet
so we are going to guess that we do have support.") ) );
+        getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("No mysql handle yet
so we are going to guess that we do have support.") );
         MYODBCDbgReturn3( "%d", SQL_TC_DML );
     }
     if ( !isConnected() )
     {
-        getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("No connection yet so
we are going to guess that we do have support.") ) );
+        getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("No connection yet so
we are going to guess that we do have support.") );
         MYODBCDbgReturn3( "%d", SQL_TC_DML );
     }
 
@@ -4604,6 +4617,8 @@
 
         We make an assumption here - that our support for transactions is limited to data
manipulation Language (DML)
         statements such as; SELECT, INSERT, DELETE, and UPDATE.
+
+        This should be in synch with MCommand behaviour.
     */
     if ( pMySQL->server_capabilities & CLIENT_TRANSACTIONS )
         MYODBCDbgReturn3( "%d", SQL_TC_DML );

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-07-12 02:57:48 UTC (rev 438)
@@ -30,6 +30,7 @@
     pDiagnostic         = new MDiagnostic( this );
     pAppParamDesc       = pAppParamDescOrig = new MDescriptorAPD( this );
     pAppRowDesc         = pAppRowDescOrig   = new MDescriptorARD( this );
+    pCommands           = NULL;
     pResult             = NULL;
     bImplicitPrepare    = false;
     nAsyncEnable        = SQL_ASYNC_ENABLE_DEFAULT;

Modified: trunk/MYSQLPlus/include/MStatement.h
===================================================================
--- trunk/MYSQLPlus/include/MStatement.h	2006-07-11 06:39:26 UTC (rev 437)
+++ trunk/MYSQLPlus/include/MStatement.h	2006-07-12 02:57:48 UTC (rev 438)
@@ -177,6 +177,7 @@
     MDiagnostic *   pDiagnostic;            /*!< Statements diagnostic.               
                         */
     MDescriptor *   pAppParamDescOrig;      /*!< Original app param desc.             
                         */
     MDescriptor *   pAppRowDescOrig;        /*!< Original app row desc.               
                         */
+    MCommands *     pCommands;              /*!< Commands (typically SQL statement(s))
are managed in this.     */
     QString         stringCursorName;       /*!< cursor name - used by pos
update/delete (WHERE CURRENT OF name)*/
     MResult *       pResult;                /*!< our result (null if N/A)             
                         */
     BOOLEAN         bImplicitPrepare;       /*!< true if prepare done implicitly ie
doExecDirect or doTables etc*/

Thread
Connector/ODBC 5 commit: r438 - in trunk/MYSQLPlus: MYSQLPlusLib includepharvey12 Jul