List:Commits« Previous MessageNext Message »
From:pharvey Date:July 26 2006 3:07pm
Subject:Connector/ODBC 5 commit: r459 - in trunk: . MYSQLPlus/MYSQLPlusLib MYSQLPlus/include examples/CPP/ADO
View as plain text  
Modified:
   trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp
   trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
   trunk/MYSQLPlus/include/MStatement.h
   trunk/connector-odbc.vpw
   trunk/examples/CPP/ADO/main.cpp
Log:
- make state changes a bit easier to understand

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommand.cpp	2006-07-26 15:07:51 UTC (rev 459)
@@ -294,7 +294,7 @@
 
     \return COMMAND_TYPE    The command type.
 */
-COMMAND_TYPE MCommand::getType()
+MCommand::COMMAND_TYPE MCommand::getType()
 {
     MYODBCDbgEnter();
 

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MConnection.cpp	2006-07-26 15:07:51 UTC (rev 459)
@@ -1992,7 +1992,7 @@
         MYODBCDbgReturn( SQL_SUCCESS );
 
     /*!
-        \internal ODBC RULE
+        \internal ODBC RULE (DM)
 
          When a driver is in autocommit mode, the Driver Manager does not call SQLEndTran
in the 
          driver. SQLEndTran always returns SQL_SUCCESS regardless of whether it is called
with a 
@@ -2021,14 +2021,6 @@
             MYODBCDbgReturn( doTransactionCommit() );
 
         case SQL_ROLLBACK:
-            /*!
-                \internal ODBC RULE
-
-                The driver or data source does not support the ROLLBACK operation.
-            */
-            if ( getInfoTxnCapable() == SQL_TC_NONE )
-                MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00 )
);
-
             MYODBCDbgReturn( doTransactionRollback() );
     }
 

Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp	2006-07-26 15:07:51 UTC (rev 459)
@@ -120,7 +120,7 @@
         The statement corresponding to StatementHandle was already in an executed or 
         cursor-positioned state.
     */
-    if ( getState() > STATE_S3 )
+    if ( isExecuted() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_24000 ) );
 
     /*!
@@ -521,7 +521,7 @@
         The function was called without first calling SQLExecDirect, 
         SQLExecute or a catalog function.
     */
-    if ( getState() < STATE_S4 )
+    if ( !isExecuted() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -891,7 +891,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -1686,7 +1686,7 @@
         The function was called prior to calling SQLPrepare, SQLExecDirect, or a catalog
function for 
         the StatementHandle.
     */
-    if ( getState() < STATE_S2 )
+    if ( !isPrepared() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -1977,7 +1977,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -2076,7 +2076,7 @@
         The function was called prior to calling SQLPrepare, SQLExecute, or a catalog
function on 
         the statement handle.
     */
-    if ( getState() < STATE_S2 )
+    if ( !isPrepared() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -2121,9 +2121,9 @@
         \internal MYODBC RULE
 
         Only server-side prepared statements (MResultStmt) can give us meta data on the
resultset
-        when we are in the prepared state.
+        prior to executing.
     */
-    if ( getState() < STATE_S4 && pResult->objectName() != "MResultStmt" )
+    if ( !isExecuted() && pResult->objectName() != "MResultStmt" )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("column attributes unknown at this time") ) );
 
     /*!
@@ -2245,15 +2245,8 @@
         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.
-
-        \note
-
-        This can also be obtained by getImpRowDesc()->getCount() because at this point

-        we have been executed - so always have good IRD.
     */
-    MCommand command = pCommands->at( pCommands->getCurrent() );
-
-    if ( command.isResultSetPossible() )
+    if ( getImpRowDesc()->getCount() )
         setState( STATE_S5 );
     else
         setState( STATE_S4 );
@@ -2280,7 +2273,7 @@
 
         The StatementHandle was not prepared.
     */
-    if ( getState() < STATE_S2 )
+    if ( !isPrepared() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -2322,7 +2315,7 @@
         call to SQLPrepare, SQLExecDirect, or one of the catalog functions (SQLColumns, 
         SQLTables, and so on).
     */
-    if ( getState() > STATE_S3 )
+    if ( isExecuted() )
         doStateRollBack( STATE_S3 );
 
     Q_ASSERT( !pResult );
@@ -2354,15 +2347,8 @@
         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.
-
-        \note
-
-        This can also be obtained by getImpRowDesc()->getCount() because at this point

-        we have been executed - so always have good IRD.
     */
-    MCommand command = pCommands->at( pCommands->getCurrent() );
-
-    if ( command.isResultSetPossible() )
+    if ( getImpRowDesc()->getCount() )
         setState( STATE_S5 );
     else
         setState( STATE_S4 );
@@ -2402,7 +2388,7 @@
         The function was called without first calling SQLExecDirect, 
         SQLExecute or a catalog function.
     */
-    if ( getState() < STATE_S4 )
+    if ( !isExecuted() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -2421,7 +2407,7 @@
         The StatementHandle was in an executed state, but no result 
         set was associated with the StatementHandle.
     */
-    if ( getState() == STATE_S4 || !pResult )
+    if ( getState() == STATE_S4 )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_24000 ) );
 
     setState( STATE_S6 );
@@ -2638,7 +2624,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -2830,7 +2816,7 @@
         The function was called prior to calling SQLPrepare, SQLExecute, or a catalog
function on 
         the statement handle.
     */
-    if ( getState() < STATE_S2 )
+    if ( !isExecuted() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -2877,7 +2863,7 @@
 
         The StatementHandle was not prepared.
     */
-    if ( getState() < STATE_S4 )
+    if ( !isPrepared() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -2907,7 +2893,7 @@
         but we do NOT do that because it provides inconsistent behaviour. The app should
use 
         server side prepared if col count needed before execute.
     */
-    if ( getState() < STATE_S4 && pResult->objectName() != "MResultStmt" )
+    if ( !isExecuted() && pResult->objectName() != "MResultStmt" )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("column count unknown at this time") ) );
 
     /*!
@@ -3039,7 +3025,7 @@
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY090 ) );
 
     /* we could be in; STATE_S2, STATE_S3 or STATE_S4 so rollback */
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
         doStateRollBack( STATE_S1 );
 
     /* get our statement text into a friendly QString */
@@ -3345,7 +3331,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -3434,7 +3420,7 @@
         The function was called without first calling SQLExecDirect, 
         SQLExecute or a catalog function.
     */
-    if ( getState() < STATE_S4 )
+    if ( !isExecuted() )
         MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
 
     /*!
@@ -3840,7 +3826,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -4082,7 +4068,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -4268,7 +4254,7 @@
         We undo any prepare - no worries.
     */
     SQLRETURN nReturn;
-    if ( getState() > STATE_S1 )
+    if ( isPrepared() )
     {
         nReturn = doStateRollBack( STATE_S1 );
         if ( !SQL_SUCCEEDED( nReturn ) )
@@ -4292,16 +4278,26 @@
     MYODBCDbgReturn( nReturn );
 }
 
-BOOLEAN MStatement::isAsyncInProgress()
+BOOLEAN MStatement::isPrepared()
 {
     MYODBCDbgEnter();
 
-    if ( getState() == MStatement::STATE_S11 ) 
+    if ( getState() >= STATE_S3 ) 
         MYODBCDbgReturn3( "%d", true );
 
     MYODBCDbgReturn3( "%d", false );
 }
 
+BOOLEAN MStatement::isExecuted()
+{
+    MYODBCDbgEnter();
+
+    if ( getState() >= STATE_S4 ) 
+        MYODBCDbgReturn3( "%d", true );
+
+    MYODBCDbgReturn3( "%d", false );
+}
+
 BOOLEAN MStatement::isDataNeeded()
 {
     MYODBCDbgEnter();
@@ -4312,6 +4308,16 @@
     MYODBCDbgReturn3( "%d", false );
 }
 
+BOOLEAN MStatement::isAsyncInProgress()
+{
+    MYODBCDbgEnter();
+
+    if ( getState() == MStatement::STATE_S11 ) 
+        MYODBCDbgReturn3( "%d", true );
+
+    MYODBCDbgReturn3( "%d", false );
+}
+
 BOOLEAN MStatement::setState( STATE nState )
 {
     MYODBCDbgEnter();

Modified: trunk/MYSQLPlus/include/MStatement.h
===================================================================
--- trunk/MYSQLPlus/include/MStatement.h	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/MYSQLPlus/include/MStatement.h	2006-07-26 15:07:51 UTC (rev 459)
@@ -86,8 +86,10 @@
     SQLRETURN doTables( SQLWCHAR *psCatalogName, SQLSMALLINT nNameLength1, SQLWCHAR
*psSchemaName, SQLSMALLINT nNameLength2, SQLWCHAR *psTableName, SQLSMALLINT nNameLength3,
SQLWCHAR *psTableType, SQLSMALLINT nNameLength4 );
 
     /* isers */
+    BOOLEAN isPrepared();
+    BOOLEAN isExecuted();
+    BOOLEAN isDataNeeded();
     BOOLEAN isAsyncInProgress();
-    BOOLEAN isDataNeeded();
 
 protected:
 

Modified: trunk/connector-odbc.vpw
===================================================================
--- trunk/connector-odbc.vpw	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/connector-odbc.vpw	2006-07-26 15:07:51 UTC (rev 459)
@@ -2,7 +2,7 @@
 <Workspace Version="10.0" VendorName="SlickEdit">
 	<Projects>
 		<Project File="dltest/dltest.vpj" />
-		<Project File="examples/CPP/7/ADO/exampleADO.vpj" />
+		<Project File="examples/CPP/ADO/exampleADO.vpj" />
 		<Project File="MYODBCBrw/MYODBCBrw.vpj" />
 		<Project File="MYODBCBrw/MYODBCBrwApp/MYODBCBrwApp.vpj" />
 		<Project File="MYODBCBrw/MYODBCBrwLib/MYODBCBrwLib.vpj" />

Modified: trunk/examples/CPP/ADO/main.cpp
===================================================================
--- trunk/examples/CPP/ADO/main.cpp	2006-07-22 18:29:27 UTC (rev 458)
+++ trunk/examples/CPP/ADO/main.cpp	2006-07-26 15:07:51 UTC (rev 459)
@@ -57,9 +57,9 @@
 
 // global connect
 _ConnectionPtr pConnection  = NULL;
-char *pszConnectionString   = "ado2";
-char *pszUserID             = "root";
-char *pszPassword           = "pharvey";
+char *pszConnectionString   = "YourDataSourceName";
+char *pszUserID             = "YourUserIdentifier";
+char *pszPassword           = "YourPassword";
 
 // sample data
 UCHAR   pDataText[]     = "12345678901234567890123456789012345678901234567890";  

Thread
Connector/ODBC 5 commit: r459 - in trunk: . MYSQLPlus/MYSQLPlusLib MYSQLPlus/include examples/CPP/ADOpharvey26 Jul