List:Commits« Previous MessageNext Message »
From:pharvey Date:November 28 2006 6:46pm
Subject:Connector/ODBC 5 commit: r701 - trunk/SDK/MYSQLPlus/Library
View as plain text  
Modified:
   trunk/SDK/MYSQLPlus/Library/MStatement.cpp
Log:
ENH: State handling improvements for MStatement to go along with data-at-exec work. More
to come.

Modified: trunk/SDK/MYSQLPlus/Library/MStatement.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MStatement.cpp	2006-11-28 14:51:56 UTC (rev 700)
+++ trunk/SDK/MYSQLPlus/Library/MStatement.cpp	2006-11-28 17:46:09 UTC (rev 701)
@@ -2848,9 +2848,9 @@
 {
     MYODBCDbgEnter();
 
-    SQLRETURN nReturn1 = doPrepare( psStatementText, nTextLength );
-    if ( !SQL_SUCCEEDED( nReturn1 ) )
-        MYODBCDbgReturn( nReturn1 );
+    SQLRETURN nReturn = doPrepare( psStatementText, nTextLength );
+    if ( !SQL_SUCCEEDED( nReturn ) )
+        MYODBCDbgReturn( nReturn );
 
     /* this controls whether or not we can roll back to prepare state */
     setImplicitPrepare( true );
@@ -2864,27 +2864,37 @@
         - we know our state is fine
         - we do not want to clear diag (it was done in doPrepare())
     */
-    MResult *pResult = getResult();
-    SQLRETURN nReturn2 = pResult->doExecute();
-    if ( !SQL_SUCCEEDED( nReturn2 ) )
+    MResult *   pResult         = getResult();
+    SQLRETURN   nReturnInternal = pResult->doExecute();
+    switch ( nReturnInternal )
     {
-        /*!
-            \internal ODBC RULE
-            \todo
+        case SQL_SUCCESS:
+            break;
+        case SQL_SUCCESS_WITH_INFO:
+            nReturn = nReturnInternal;
+            break;
+        case SQL_NEED_DATA:
+            /*!
+                \internal ODBC RULE
 
-            If SQLExecute executes a searched update or delete statement that does 
-            not affect any rows at the data source, the call to SQLExecute returns 
-            SQL_NO_DATA.
-        */
-        /*!
-            \internal ODBC RULE
-            \todo
+                If SQLExecute encounters a data-at-execution parameter, it returns 
+                SQL_NEED_DATA. The application sends the data using SQLParamData and 
+                SQLPutData.
+            */
+            setState( STATE_S8 );
+            MYODBCDbgReturn( nReturnInternal );
+        case SQL_NO_DATA:
+            /*!
+                \internal ODBC RULE
+                \todo
 
-            If SQLExecute encounters a data-at-execution parameter, it returns 
-            SQL_NEED_DATA. The application sends the data using SQLParamData and 
-            SQLPutData.
-        */
-        MYODBCDbgReturn( nReturn2 );
+                If SQLExecute executes a searched update or delete statement that does 
+                not affect any rows at the data source, the call to SQLExecute returns 
+                SQL_NO_DATA.
+            */
+            MYODBCDbgReturn( nReturnInternal );
+        default:
+            MYODBCDbgReturn( nReturnInternal );
     }
 
     /*!
@@ -2899,10 +2909,7 @@
     else
         setState( STATE_S4 );
 
-    if ( nReturn1 == SQL_SUCCESS_WITH_INFO || nReturn2 == SQL_SUCCESS_WITH_INFO )
-        MYODBCDbgReturn( SQL_SUCCESS_WITH_INFO );
-
-    MYODBCDbgReturn( SQL_SUCCESS );
+    MYODBCDbgReturn( nReturn );
 }
 
 SQLRETURN MStatement::doExecute()
@@ -3833,7 +3840,44 @@
     */
     pDiagnostic->doClear();
 
-    MYODBCDbgReturn( getResult()->doParamData( ppValuePtrPtr ) );
+    SQLRETURN nReturn = getResult()->doParamData( ppValuePtrPtr );
+
+    switch ( nReturn )
+    {
+        case SQL_SUCCESS:
+        case SQL_SUCCESS_WITH_INFO:
+            break;
+        case SQL_NEED_DATA:
+            if ( getState() == STATE_S8 )
+                setState( STATE_S9 );
+            MYODBCDbgReturn( nReturn );
+        case SQL_NO_DATA:
+            /*!
+                \internal ODBC RULE
+                \todo
+
+                If SQLExecute executes a searched update or delete statement that does 
+                not affect any rows at the data source, the call to SQLExecute returns 
+                SQL_NO_DATA.
+            */
+            MYODBCDbgReturn( nReturn );
+        default:
+            MYODBCDbgReturn( nReturn );
+    }
+
+    /*!
+        \internal ODBC RULE
+
+        No columns then no resultset - set state accordingly. Being in state S5 does
+        not imply that we have data/rows in the resultset - just that we have a 
+        resultset.
+    */
+    if ( getImpRowDesc()->getCount() )
+        doStateRollBack( STATE_S5 );
+    else
+        doStateRollBack( STATE_S4 );
+
+    MYODBCDbgReturn( nReturn );
 }
 
 /*!
@@ -4537,7 +4581,12 @@
         source     */
 
-    MYODBCDbgReturn( getResult()->doPutData( pDataPtr, nStrLenOrInd ) );
+    SQLRETURN nReturn = getResult()->doPutData( pDataPtr, nStrLenOrInd );
+
+    if ( getState() == STATE_S9 )
+        setState( STATE_S10 );
+
+    MYODBCDbgReturn( nReturn );
 }
 
 SQLRETURN MStatement::doRowCount( SQLINTEGER *pnRowCount )

Thread
Connector/ODBC 5 commit: r701 - trunk/SDK/MYSQLPlus/Librarypharvey28 Nov