Modified:
trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
trunk/MYSQLPlus/MYSQLPlusLib/MCommands.h
trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
more work on SQLMoreResults
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp 2006-07-27 20:07:04 UTC (rev 461)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommands.cpp 2006-07-28 00:05:54 UTC (rev 462)
@@ -16,7 +16,7 @@
Q_ASSERT( !pConnection );
this->pConnection = pConnection;
pStatement = NULL;
- nCurrent = 0;
+ nPos = -1;
MYODBCDbgReturn2();
}
@@ -28,7 +28,7 @@
Q_ASSERT( !pStatement );
this->pStatement = pStatement;
pConnection = pStatement->getConnection();
- nCurrent = -1;
+ nPos = -1;
MYODBCDbgReturn2();
}
@@ -53,7 +53,7 @@
QString stringCommand;
/* clear out any previous commands processing */
- clear();
+ doClear();
for ( int nChar = 0; nChar < stringCommands.length(); nChar++ )
{
@@ -65,6 +65,7 @@
( !cQuote.isNull() && cQuote != cChar ) || /* last
char is not going to close our quote */
( cQuote.isNull() && stringQuotes.contains( cChar ) ) ) /* last
char is going to open a quote */
{
+ doClear();
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "unclosed quote near: " ).arg( stringCommand ) ) );
}
@@ -89,8 +90,8 @@
nReturn = n;
break;
default:
- nReturn = n;
- MYODBCDbgReturn( nReturn );
+ doClear();
+ MYODBCDbgReturn( n );
}
append( command );
}
@@ -106,8 +107,8 @@
nReturn = n;
break;
default:
- nReturn = n;
- MYODBCDbgReturn( nReturn );
+ doClear();
+ MYODBCDbgReturn( n );
}
append( command );
}
@@ -127,18 +128,22 @@
}
this->stringCommands = stringCommands;
+ doFirst();
MYODBCDbgReturn( nReturn );
}
-BOOLEAN MCommands::setCurrent( int nCurrent )
+BOOLEAN MCommands::setPos( int nPos )
{
MYODBCDbgEnter();
- if ( nCurrent < -1 || nCurrent > (count() - 1) )
+ if ( nPos < 0 || nPos >= count() )
+ {
+ nPos = -1;
MYODBCDbgReturn3( "%d", false );
+ }
- this->nCurrent = nCurrent;
+ this->nPos = nPos;
MYODBCDbgReturn3( "%d", true );
}
@@ -215,27 +220,42 @@
MYODBCDbgReturn3( "%p", listParameterMarkers );
}
-int MCommands::getCurrent()
+int MCommands::getPos()
{
MYODBCDbgEnter();
- MYODBCDbgReturn3( "%d", nCurrent );
+ MYODBCDbgReturn3( "%d", nPos );
}
-BOOLEAN MCommands::doNext()
+BOOLEAN MCommands::doClear()
{
MYODBCDbgEnter();
- nCurrent++;
- if ( nCurrent > count() )
- {
- nCurrent = -1;
- MYODBCDbgReturn3( "%d", false );
- }
+ clear();
+ nPos = -1;
+ stringCommands.clear();
MYODBCDbgReturn3( "%d", true );
}
+BOOLEAN MCommands::doFirst()
+{
+ MYODBCDbgEnter();
+
+ BOOLEAN b = setPos( 0 );
+
+ MYODBCDbgReturn3( "%d", b );
+}
+
+BOOLEAN MCommands::doNext()
+{
+ MYODBCDbgEnter();
+
+ BOOLEAN b = setPos( nPos++ );
+
+ MYODBCDbgReturn3( "%d", b );
+}
+
/*!
\internal
\brief Used to determine if command is going to honour any transaction it may be a
party to.
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MCommands.h
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MCommands.h 2006-07-27 20:07:04 UTC (rev 461)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MCommands.h 2006-07-28 00:05:54 UTC (rev 462)
@@ -51,16 +51,18 @@
/* setters */
SQLRETURN setCommands( const QString &stringCommands ); // this can include
ODBC specifics not supported by server
- BOOLEAN setCurrent( int nCurrent ); // set current command (0 based)
+ BOOLEAN setPos( int nPos ); // set current command (0 based)
/* getters */
- QString getCommands(); // simply returns the text provided to
setCommands()
- QString getNative(); // version of text which has any ODBC specifics
switched to server friendly syntax etc (prepared)
- QList<int> getParameterMarkers(); // list of index pos into native commands
string where we can find parameter marker ( '?' )
- int getCurrent(); // return current
- MCommand getCurrentCommand(); // return current
+ QString getCommands(); // simply returns the text provided to
setCommands()
+ QString getNative(); // version of text which has any ODBC specifics
switched to server friendly syntax etc (prepared)
+ QList<int> getParameterMarkers(); // list of index pos into native commands
string where we can find parameter marker ( '?' )
+ int getPos(); // return current
+ MCommand getCommand(); // return current
/* doers */
+ BOOLEAN doClear();
+ BOOLEAN doFirst();
BOOLEAN doNext();
/* isers */
@@ -75,10 +77,10 @@
MDiagnostic * getDiagnostic();
private:
- MConnection * pConnection; /*!< connection we are supporting
*/
- MStatement * pStatement; /*!< statement we are supporting (null
if we just supporting the connection) */
- QString stringCommands; /*!< commands string as provided to
setCommands() */
- int nCurrent; /*!< current command (0-based with
-1=eof) */
+ MConnection * pConnection; /*!< connection we are supporting
*/
+ MStatement * pStatement; /*!< statement we are supporting (null if we just
supporting the connection) */
+ QString stringCommands; /*!< commands string as provided to setCommands()
*/
+ int nPos; /*!< current command (0-based with -1=eof)
*/
};
#endif
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-07-27 20:07:04 UTC (rev 461)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-07-28 00:05:54 UTC (rev 462)
@@ -2813,15 +2813,18 @@
doStateRollBack( STATE_S3 );
/* advance to next command */
+ if ( pCommands->doNext() )
+ {
+ delete pResult;
+ pResult->doPrepare();
+ pResult->doExecute();
+ }
+ else
+ {
+ /* no more commands */
+ }
- delete pResult;
-
- /* advance to next command */
- pCommands->setCurrent( pCommands->getCurrent() + 1 );
-
- doPrepare( );
-
- MYODBCDbgReturn( SQL_ERROR );
+ MYODBCDbgReturn( SQL_SUCCESS );
}
/*!
| Thread |
|---|
| • Connector/ODBC 5 commit: r462 - trunk/MYSQLPlus/MYSQLPlusLib | pharvey | 28 Jul |