Modified:
trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
Modified: trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-07-28 00:05:54 UTC (rev 462)
+++ trunk/MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-07-29 05:37:54 UTC (rev 463)
@@ -2809,6 +2809,10 @@
server before executing the next command.
*/
+ /*
+ * PREPARE
+ */
+
/* rollback to prepared state */
doStateRollBack( STATE_S3 );
@@ -2816,14 +2820,26 @@
if ( pCommands->doNext() )
{
delete pResult;
- pResult->doPrepare();
- pResult->doExecute();
+ pResult = NULL;
+
+ nReturn = doPrepare( pCommands->getCommand() );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ {
+ MYODBCDbgReturn( nReturn );
+ }
}
else
{
/* no more commands */
+ MYODBCDbgReturn( SQL_NO_DATA );
}
+ /*
+ * EXECUTE
+ */
+
+ pResult->doExecute();
+
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -3006,8 +3022,6 @@
{
MYODBCDbgEnter();
- MCommand command;
-
/*!
\internal ODBC RULE
@@ -3106,79 +3120,13 @@
goto doPrepareExit1;
}
- /* get 1st command - this is the one we will prepare for execute now */
- command = pCommands->at( pCommands->getCurrent() );
-
- /* what flavour of resultset do we want? */
- int nStatementType = getConnection()->getStatementType();
-
- /*!
- \internal
- \todo
-
- Make us smart enough to decide based upon the;
-
- - environment attributes
- - connection attributes
- - statement attributes
- - client feature support
- - server feature support
- - SQL statement
- - resultset characteristics expected (if possible)
-
- Our bias is toward using server-side prepared.
- */
- if ( nStatementType == MConnection::STATEMENT_DYNAMIC )
- {
- if ( command.isServerSidePreparePossible() )
- nStatementType = MConnection::STATEMENT_STMT;
- else
- nStatementType = MConnection::STATEMENT_RES;
- }
-
- /* if app wants server-side prepare but we can not use it then we fall back to
client-side and throw a warning */
- if ( nStatementType == MConnection::STATEMENT_STMT &&
!command.isServerSidePreparePossible() )
- {
- getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("STATEMENT_STMT will
not support command - will use STATEMENT_RES instead") );
- nStatementType = MConnection::STATEMENT_RES;
- }
-
- /* create appropriate resultset object */
- switch ( nStatementType )
- {
- case MConnection::STATEMENT_DYNAMIC:
- case MConnection::STATEMENT_RES:
- pResult = new MResultRes( this );
- break;
-
- case MConnection::STATEMENT_STMT:
- pResult = new MResultStmt( this );
- break;
-
- default:
- nReturn = getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, QString(
tr("Unknown statement type %1") ).arg( nStatementType ) );
- goto doPrepareExit1;
- }
-
- /* ask resultset to do any further prepare */
- nReturn = doPrepare( command );
+ /* first command is current by default - this is the one we will prepare for execute
now */
+ nReturn = doPrepare( pCommands->getCommand() );
if ( !SQL_SUCCEEDED( nReturn ) )
{
goto doPrepareExit2;
}
- /*!
- \internal
- \todo
-
- Set SQL_DIAG_DYNAMIC_FUNCTION and SQL_DIAG_DYNAMIC_FUNCTION_CODE diagnostic
header fields and possibly use them instead
- of statement type.
- */
- if ( command.isResultSetPossible() )
- setState( STATE_S3 );
- else
- setState( STATE_S2 );
-
MYODBCDbgReturn( nReturn );
doPrepareExit2:
@@ -5310,8 +5258,7 @@
nState = STATE_S3; // we will have a resultset
else
{
- MCommand c = pCommands->at( pCommands->getCurrent() );
- if ( c.isResultSetPossible() )
+ if ( pCommands->getCommand().isResultSetPossible() )
nState = STATE_S3; // we will have a resultset
}
setState( nState );
@@ -5367,6 +5314,57 @@
{
MYODBCDbgEnter();
+ /* what flavour of resultset do we want? */
+ int nStatementType = getConnection()->getStatementType();
+
+ /*!
+ \internal
+ \todo
+
+ Make us smart enough to decide based upon the;
+
+ - environment attributes
+ - connection attributes
+ - statement attributes
+ - client feature support
+ - server feature support
+ - SQL statement
+ - resultset characteristics expected (if possible)
+
+ Our bias is toward using server-side prepared.
+ */
+ if ( nStatementType == MConnection::STATEMENT_DYNAMIC )
+ {
+ if ( command.isServerSidePreparePossible() )
+ nStatementType = MConnection::STATEMENT_STMT;
+ else
+ nStatementType = MConnection::STATEMENT_RES;
+ }
+
+ /* if app wants server-side prepare but we can not use it then we fall back to
client-side and throw a warning */
+ if ( nStatementType == MConnection::STATEMENT_STMT &&
!command.isServerSidePreparePossible() )
+ {
+ getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, tr("STATEMENT_STMT will
not support command - will use STATEMENT_RES instead") );
+ nStatementType = MConnection::STATEMENT_RES;
+ }
+
+ /* create appropriate resultset object */
+ switch ( nStatementType )
+ {
+ case MConnection::STATEMENT_DYNAMIC:
+ case MConnection::STATEMENT_RES:
+ pResult = new MResultRes( this );
+ break;
+
+ case MConnection::STATEMENT_STMT:
+ pResult = new MResultStmt( this );
+ break;
+
+ default:
+ nReturn = getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, QString(
tr("Unknown statement type %1") ).arg( nStatementType ) );
+ goto doPrepareExit1;
+ }
+
SQLRETURN nReturn = pResult->doPrepare( command );
if ( !SQL_SUCCEEDED( nReturn ) )
MYODBCDbgReturn( nReturn );
@@ -5401,6 +5399,18 @@
}
}
+ /*!
+ \internal
+ \todo
+
+ Set SQL_DIAG_DYNAMIC_FUNCTION and SQL_DIAG_DYNAMIC_FUNCTION_CODE diagnostic
header fields and possibly use them instead
+ of statement type.
+ */
+ if ( command.isResultSetPossible() )
+ setState( STATE_S3 );
+ else
+ setState( STATE_S2 );
+
MYODBCDbgReturn( nReturn );
}
| Thread |
|---|
| • Connector/ODBC 5 commit: r463 - trunk/MYSQLPlus/MYSQLPlusLib | pharvey | 29 Jul |