Modified:
MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
MYSQLPlus/MYSQLPlusLib/MStatement.cpp
MYSQLPlus/MYSQLPlusLib/MYSQLPlusLib.pro
MYSQLPlus/include/MConnection.h
Log:
Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-05-09 20:41:13 UTC (rev 214)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-05-09 21:21:09 UTC (rev 215)
@@ -45,7 +45,7 @@
MYODBCResDriver
*/
MResultStmt::MResultStmt( MYODBCAttStatement *patt, MYSQL *pmysql )
- : MYODBCRes( patt, pmysql )
+ : MResult( patt, pmysql )
{
MYODBCDbgEnter();
Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-05-09 20:41:13 UTC (rev 214)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-05-09 21:21:09 UTC (rev 215)
@@ -1399,71 +1399,127 @@
*/
pDiagnostic->doClear();
- SQLRETURN nReturn;
+ /*!
+ \internal ODBC RULE (DM)
- MYODBCDbgEnter( "MYODBCDrvPrepare" );
+ A cursor was open on the StatementHandle, and SQLFetch or
+ SQLFetchScroll had been called.
+ */
+ if ( getState() == STATE_S6 )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_24000 ) );
- /*
- \internal ODBC Rule
+ /*!
+ \internal ODBC RULE (DM)
- (DM) An asynchronously executing function (not this one) was called
- for the StatementHandle and was still executing when this function was
- called.
+ A cursor was open on the StatementHandle, but SQLFetch or SQLFetchScroll
+ had not been called.
*/
- if ( pStm->nState >= MYODBC_DRV_STATE_S11 )
- MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY010, 0, NULL ) );
+ if ( getState() == STATE_S5 )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_24000 ) );
- /*
- \internal ODBC Rule
+ /*!
+ \internal ODBC RULE (DM)
- (DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was
- called for the StatementHandle and returned SQL_NEED_DATA. This
- function was called before data was sent for all data-at-execution
- parameters or columns.
+ StatementText was a null pointer.
*/
- if ( pStm->nState >= MYODBC_DRV_STATE_S8 )
- MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY010, 0, NULL ) );
+ if ( !psStatementText )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY009 ) );
- /*
- \internal ODBC Rule
+ /*!
+ \internal ODBC RULE (DM)
- 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.
+ An asynchronously executing function was called for the
+ StatementHandle and was still executing when this function
+ was called.
- A result set was open on the StatementHandle, but SQLFetch or
- SQLFetchScroll had not been called.
+ \note
+
+ DM should handle this but check here in case where app is linked
+ directly to driver.
*/
- if ( pStm->nState >= MYODBC_DRV_STATE_S5 )
- MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_24000, 0, NULL ) );
+ if ( isAsyncInProgress() )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
- /* cleanup from any previous processing */
- if ( pStm->nState > MYODBC_DRV_STATE_S1 )
+ /*!
+ \internal ODBC RULE (DM)
+
+ SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was
+ called for the StatementHandle and returned SQL_NEED_DATA.
+ This function was called before data was sent for all
+ data-at-execution parameters or columns.
+ */
+ if ( isDataNeeded() )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY010 ) );
+
+ /*!
+ \internal ODBC RULE (DM)
+
+ The argument TextLength was less than or equal to 0 but not equal to SQL_NTS.
+ */
+ if ( nLength1 <= 0 && nLength1 != SQL_NTS )
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HY090 ) );
+
+ /*!
+ \internal ODBC RULE
+
+ The prepared statement associated with the statement handle can be reexecuted by
+ calling SQLExecute until the application frees the statement with a call to
+ SQLFreeStmt with the SQL_DROP option or until the statement handle is used in a
+ call to SQLPrepare, SQLExecDirect, or one of the catalog functions (SQLColumns,
+ SQLTables, and so on).
+ */
+ if ( getState() > STATE_S1 )
{
- SQLRETURN nReturn = MYODBCDrvSetStmState( pStm, MYODBC_DRV_STATE_S1 );
- if ( !SQL_SUCCEEDED( nReturn ) )
- MYODBCDbgReturn( nReturn );
+ Q_ASSERT( !pResult );
+ delete pResult;
+ pResult = NULL;
+ setState( STATE_S1 );
}
- /*! \todo decide what kind of result to create here based upon options/attributes */
- if ( MYODBCResAlloc( MYODBC_RES_METHOD_RES,
- pStm->hDia,
- pStm->attr_imp_row_desc,
- pStm->pDbc->pMySQL,
- &pStm->hRes ) != SQL_SUCCESS )
- MYODBCDbgReturn( MYODBCDiaAppend( pStm->hDia, MYODBC_DIA_HY000, 0, "Failed to
prepare an empty result." ) );
+ /* what flavour of resultset do we want? */
+ switch ( getStatementType() )
+ {
+ case STATEMENT_RES:
+ /*!
+ \internal
+ \todo
- nReturn = MYODBCResPrepare( pStm->hRes, pszStatementText, nLength1 );
+ Use MResultRes here.
+ */
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_IM001 ) );
+
+ case STATEMENT_DYNAMIC:
+ /*!
+ \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)
+ */
+ MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_01000, 0,
tr("STATEMENT_DYNAMIC is same as STATEMENT_STMT at this time") ) );
+
+ case STATEMENT_STMT:
+ pResult = new MResultStmt( this );
+ break;
+ }
+
+ /* do it */
+ SQLRETURN nReturn = pResult->doPrepare( psStatementText );
if ( !SQL_SUCCEEDED( nReturn ) )
{
- MYODBCResFree( pStm->hRes );
- pStm->hRes = NULL;
- MYODBCDbgReturn( nReturn );
+ Q_ASSERT( !pResult );
+ delete pResult;
+ pResult = NULL;
}
- /* new state - we have some form of statement */
- MYODBCDrvSetStmState( pStm, MYODBC_DRV_STATE_S3 );
+ setState( STATE_S3 );
MYODBCDbgReturn( nReturn );
}
Modified: MYSQLPlus/MYSQLPlusLib/MYSQLPlusLib.pro
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MYSQLPlusLib.pro 2006-05-09 20:41:13 UTC (rev 214)
+++ MYSQLPlus/MYSQLPlusLib/MYSQLPlusLib.pro 2006-05-09 21:21:09 UTC (rev 215)
@@ -26,6 +26,7 @@
../include/MDescriptor.h \
MResult.h \
MResultPlus.h \
+ MResultStmt.h \
MDescriptorAPD.h \
MDescriptorARD.h \
MDescriptorIPD.h \
@@ -46,6 +47,7 @@
MDescriptor.cpp \
MResult.cpp \
MResultPlus.cpp \
+ MResultStmt.cpp \
MDescriptorAPD.cpp \
MDescriptorARD.cpp \
MDescriptorIPD.cpp \
Modified: MYSQLPlus/include/MConnection.h
===================================================================
--- MYSQLPlus/include/MConnection.h 2006-05-09 20:41:13 UTC (rev 214)
+++ MYSQLPlus/include/MConnection.h 2006-05-09 21:21:09 UTC (rev 215)
@@ -27,7 +27,6 @@
STATEMENT_RES, /*!< MYSQL_RES based processing
*/
STATEMENT_STMT, /*!< MYSQL_STMT based processing
*/
STATEMENT_DYNAMIC /*!< MYSQLPlus selects based upon connection/statement
attributes */
-
};
/* setters */
| Thread |
|---|
| • Connector/ODBC 5 commit: r215 - in MYSQLPlus: MYSQLPlusLib include | pharvey | 9 May |