List:Commits« Previous MessageNext Message »
From:pharvey Date:May 13 2006 11:53pm
Subject:Connector/ODBC 5 commit: r234 - MYODBCDriver/MYODBCDriverLib MYSQLPlus/MYSQLPlusLib
View as plain text  
Modified:
   MYODBCDriver/MYODBCDriverLib/SQLPrepareW.cpp
   MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:


Modified: MYODBCDriver/MYODBCDriverLib/SQLPrepareW.cpp
===================================================================
--- MYODBCDriver/MYODBCDriverLib/SQLPrepareW.cpp	2006-05-13 23:13:32 UTC (rev 233)
+++ MYODBCDriver/MYODBCDriverLib/SQLPrepareW.cpp	2006-05-13 23:53:03 UTC (rev 234)
@@ -8,6 +8,23 @@
 */
 #include "MYODBCDriverInternal.h"
 
+/*!
+    \brief  <B>ODBC 1.0 API</B>
+            <BR>
+            Prepares an SQL string for execution.
+
+    \param  hStm                Viable statement handle.
+    \param  pszStatementText    SQL statement to prepare.
+    \param  nLength1            Length of SQL statement (or SQL_NTS).
+
+    \return SQLRETURN
+
+    \retval SQL_SUCCESS             Request processed ok.
+    \retval SQL_SUCCESS_WITH_INFO   Request was probably processed ok - check diagnostic.
+    \retval SQL_STILL_EXECUTING     Still executing from a previous call.     
+    \retval SQL_ERROR               Request failed.
+    \retval SQL_INVALID_HANDLE      Invalid handle was provided.
+*/
 SQLRETURN SQL_API SQLPrepareW( SQLHSTMT      hStm,
                                SQLWCHAR *    psStatementText,
                                SQLINTEGER    nLength1 )

Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-13 23:13:32 UTC (rev 233)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-05-13 23:53:03 UTC (rev 234)
@@ -1247,11 +1247,57 @@
 {
     MYODBCDbgEnter();
 
-    SQLRETURN nReturn = doPrepare( psStatementText, SQLINTEGER nTextLength );
-    if ( !SQL_SUCCEEDED( nReturn ) )
-        MYODBCDbgReturn( nReturn );
+    SQLRETURN nReturn1 = doPrepare( psStatementText, nTextLength );
+    if ( !SQL_SUCCEEDED( nReturn1 ) )
+        MYODBCDbgReturn( nReturn1 );
 
-    MYODBCDbgReturn( doExecute() );
+    /*!
+        \internal
+        \note
+
+        Do not do this->doExecute() because;
+
+        - we know our state is fine
+        - we do not want to clear diag (it was done in doPrepare())
+    */
+    SQLRETURN nReturn2 = pResult->doExecute();
+    if ( !SQL_SUCCEEDED( nReturn2 ) )
+    {
+        /*!
+            \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.
+        */
+        /*!
+            \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 );
+    }
+
+    /*!
+        \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() )
+        setState( STATE_S5 );
+    else
+        setState( STATE_S4 );
+
+    if ( nReturn1 == SQL_SUCCESS_WITH_INFO || nReturn2 == SQL_SUCCESS_WITH_INFO )
+        MYODBCDbgReturn( SQL_SUCCESS_WITH_INFO );
+
+    MYODBCDbgReturn( SQL_SUCCESS );
 }
 
 SQLRETURN MStatement::doExecute()
@@ -1265,7 +1311,74 @@
     */
     pDiagnostic->doClear();
 
-    MYODBCDbgReturn( SQL_ERROR );
+    /*!
+        \todo
+
+        Review handling of state changes.
+    */
+
+
+    if ( pStm->nState < MYODBC_DRV_STATE_S2 )
+        MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_24000, 0, NULL ) );
+
+    /*!
+        \internal ODBC Rule
+
+        A cursor was open on the StatementHandle, and SQLFetch or SQLFetchScroll 
+        had been called. This error is returned by the Driver Manager if 
+        SQLFetch or SQLFetchScroll has not returned SQL_NO_DATA, and is returned 
+        by the driver if SQLFetch or SQLFetchScroll has returned SQL_NO_DATA.
+
+        A result set was open on the StatementHandle, but SQLFetch or 
+        SQLFetchScroll had not been called.
+    */
+    if ( pStm->nState >= MYODBC_DRV_STATE_S5 )
+        MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_24000, 0, NULL ) );
+
+    /* cleanup from any previous processing */
+    if ( pStm->nState > MYODBC_DRV_STATE_S3 )
+    {
+        SQLRETURN nReturn = MYODBCDrvSetStmState( pStm, MYODBC_DRV_STATE_S3 );
+        if ( !SQL_SUCCEEDED( nReturn ) )
+            MYODBCDbgReturn( nReturn );
+    }
+
+    Q_ASSERT( !pResult );
+    SQLRETURN nReturn2 = pResult->doExecute();
+    if ( !SQL_SUCCEEDED( nReturn2 ) )
+    {
+        /*!
+            \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.
+        */
+        /*!
+            \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 );
+    }
+
+    /*!
+        \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() )
+        setState( STATE_S5 );
+    else
+        setState( STATE_S4 );
+
+    MYODBCDbgReturn( nReturn );
 }
 
 SQLRETURN MStatement::doExtendedFetch( SQLUSMALLINT nFetchOrientation, SQLINTEGER
nFetchOffset, SQLUINTEGER *pnRowCountPtr, SQLUSMALLINT *pnRowStatusArray )

Thread
Connector/ODBC 5 commit: r234 - MYODBCDriver/MYODBCDriverLib MYSQLPlus/MYSQLPlusLibpharvey14 May