Modified:
trunk/SDK/MYSQLPlus/Library/MResult.cpp
trunk/SDK/MYSQLPlus/Library/MResult.h
trunk/SDK/MYSQLPlus/Library/MResultPlus.h
trunk/SDK/MYSQLPlus/Library/MResultRes.cpp
trunk/SDK/MYSQLPlus/Library/MResultRes.h
Log:
- changes/additions for block-cursor support
Modified: trunk/SDK/MYSQLPlus/Library/MResult.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.cpp 2006-09-13 22:12:39 UTC (rev 543)
+++ trunk/SDK/MYSQLPlus/Library/MResult.cpp 2006-09-14 19:33:25 UTC (rev 544)
@@ -743,6 +743,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doFirst_();
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
@@ -797,6 +801,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doLast_();
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
@@ -882,6 +890,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doNext_();
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
@@ -991,6 +1003,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doPrev_();
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
@@ -1144,6 +1160,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doSkip_( nRows );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
@@ -1306,6 +1326,10 @@
resultSetData.doClear();
resultGetData.doClear();
+ SQLRETURN nReturn = doGoto_( nRow );
+ if ( !SQL_SUCCEEDED( nReturn ) )
+ MYODBCDbgReturn( nReturn );
+
/*!
\internal ODBC RULE
Modified: trunk/SDK/MYSQLPlus/Library/MResult.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.h 2006-09-13 22:12:39 UTC (rev 543)
+++ trunk/SDK/MYSQLPlus/Library/MResult.h 2006-09-14 19:33:25 UTC (rev 544)
@@ -419,6 +419,13 @@
virtual SQLRETURN doRefreshArray( SQLUINTEGER nRowSetRow );
virtual SQLRETURN doRefreshArray( SQLUINTEGER nRowSetRow, SQLUINTEGER nLength );
+ virtual SQLRETURN doFirst_() = 0;
+ virtual SQLRETURN doGoto_( qulonglong nRow ) = 0;
+ virtual SQLRETURN doLast_() = 0;
+ virtual SQLRETURN doNext_() = 0;
+ virtual SQLRETURN doPrev_() = 0;
+ virtual SQLRETURN doSkip_( qlonglong nRowSets ) = 0;
+
/*!
\name from*SQL
Modified: trunk/SDK/MYSQLPlus/Library/MResultPlus.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultPlus.h 2006-09-13 22:12:39 UTC (rev 543)
+++ trunk/SDK/MYSQLPlus/Library/MResultPlus.h 2006-09-14 19:33:25 UTC (rev 544)
@@ -83,6 +83,13 @@
SQLRETURN doApplyCursorRestrictions();
SQLRETURN doAppendVarChar();
+ SQLRETURN doFirst_() { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+ SQLRETURN doGoto_( qulonglong ) { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+ SQLRETURN doLast_() { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+ SQLRETURN doNext_() { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+ SQLRETURN doPrev_() { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+ SQLRETURN doSkip_( qlonglong ) { MYODBCDbgEnter(); MYODBCDbgReturn( SQL_SUCCCESS
); }
+
private:
QStringList stringlistTableTypesPossible; /*!< supports SQLTables */
Modified: trunk/SDK/MYSQLPlus/Library/MResultRes.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultRes.cpp 2006-09-13 22:12:39 UTC (rev 543)
+++ trunk/SDK/MYSQLPlus/Library/MResultRes.cpp 2006-09-14 19:33:25 UTC (rev 544)
@@ -376,37 +376,96 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
-SQLRETURN MResultRes::doFirst()
+/*!
+ \brief Prepares for a \sa doFirst.
+*/
+SQLRETURN MResultRes::doFirst_()
{
MYODBCDbgEnter();
SQLRETURN nReturn1 = SQL_SUCCESS;
- SQLRETURN nReturn2 = SQL_SUCCESS;
switch ( getBuffered() )
{
case BUFFERED_UNBUFFERED:
- break;
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY106 ) );
+
case BUFFERED_MYSQL_PLUS:
// have we buffered everything yet?
if ( !isResultSetRowsKnown() )
{
+ // do we need to load more data into our buffered ResultSet?
if ( getResultSetRows() < getRowSetSize() )
- nReturn = getRowSetData();
+ nReturn1 = getRowSetData();
}
break;
+
case BUFFERED_MYSQL_CLIENT:
mysql_data_seek( pRes, 0 );
+ // load RowSet
+ nReturn1 = getRowSetData();
break;
+
default:
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Unknown buffer type.") ) );
}
- nReturn2 = MResult::doFirst();
+ MYODBCDbgReturn( nReturn1 );
+}
+/*!
+ \brief Prepares for a \sa doGoto.
+*/
+SQLRETURN MResultRes::doGoto_( qulonglong nRow )
+{
+ MYODBCDbgEnter();
+
+ if ( getState() < STATE_EXECUTED )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
+
+ SQLRETURN nReturn1 = SQL_SUCCESS;
+
+ switch ( getBuffered() )
+ {
+ case BUFFERED_UNBUFFERED:
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY106 ) );
+
+ case BUFFERED_MYSQL_PLUS:
+ // have we buffered everything yet?
+ if ( !isResultSetRowsKnown() )
+ {
+ // do we need to load more data into our buffered ResultSet?
+ if ( getResultSetRows() < getRowSetSize() )
+ nReturn1 = getRowSetData();
+ }
+ break;
+
+ case BUFFERED_MYSQL_CLIENT:
+ // in case we change to signed (as per ODBC spec)
+ if ( nRow < 0 )
+ nRow = 0;
+
+ if ( nRow >= getResultSetRows() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_01S06 )
);
+
+ mysql_data_seek( pRes, nRow );
+ // load RowSet
+ nReturn1 = getRowSetData();
+ break;
+
+ default:
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Unknown buffer type.") ) );
+ }
+
+ SQLRETURN nReturn2 = MResult::doGoto( nRow, bRefresh );
+
+ if ( !SQL_SUCCEEDED( nReturn1 ) )
+ MYODBCDbgReturn( nReturn1 );
+
MYODBCDbgReturn( nReturn2 );
}
+
/*!
\brief Use this to insert a new, blank, row.
@@ -434,27 +493,10 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doInsert() not supported in this context") ) );
}
-/*!
- \brief Make the last row in the result-set the current row.
-
- This will make the last row in the result-set the current row.
- If no rows exist the current row will be invalid and SQL_NO_DATA will be
- returned.
-
- The row data will be refreshed and any bound columns will be updated.
-
- \return SQLRETURN
-
- \sa setRow
- getRow
- getRows
- doNext
- doPrev
- doFirst
- doLast
- doSkip
+/*!
+ \brief Prepares for a \sa doLast.
*/
-SQLRETURN MResultRes::doLast()
+SQLRETURN MResultRes::doLast_()
{
MYODBCDbgEnter();
@@ -470,30 +512,10 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doLast() not supported in this context") ) );
}
-/*!
- \brief Make the next row in the result-set the current row.
-
- This will make the next row in the result-set the current row.
-
- If this call causes the current row to move beyond the last row then
- the current row is invalid and SQL_NO_DATA is returned. A subsequent call
- to doNext will make the 1st row current. A subsequent call to doPrev
- will make the last row current.
-
- The row data will be refreshed and any bound columns will be updated.
-
- \return SQLRETURN
-
- \sa setRow
- getRow
- getRows
- doNext
- doPrev
- doFirst
- doLast
- doSkip
+/*!
+ \brief Prepares for a \sa doNext.
*/
-SQLRETURN MResultRes::doNext()
+SQLRETURN MResultRes::doNext_()
{
MYODBCDbgEnter();
@@ -529,30 +551,10 @@
MYODBCDbgReturn( SQL_ERROR );
}
-/*!
- \brief Make the previous row in the result-set the current row.
-
- This will make the previous row in the result-set the current row.
-
- If this call causes the current row to move before the first row then
- the current row is invalid and SQL_NO_DATA is returned. A subsequent call
- to doPrev will make the last row current. A subsequent call to doNext
- will make the first row current.
-
- The row data will be refreshed and any bound columns will be updated.
-
- \return SQLRETURN
-
- \sa setRow
- getRow
- getRows
- doNext
- doPrev
- doFirst
- doLast
- doSkip
+/*!
+ \brief Prepares for a \sa doPrev.
*/
-SQLRETURN MResultRes::doPrev()
+SQLRETURN MResultRes::doPrev_()
{
MYODBCDbgEnter();
@@ -568,29 +570,10 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doPrev() not supported in this context") ) );
}
-/*!
- \brief Set the current row relative to where we are now.
-
- This call does not actually skip through rows - it simply jumps to the row at
nRows
- from current row.
-
- If the resulting row is invalid SQL_NO_DATA is returned and the current row
becomes
- the row before the first row in the result-set.
-
- The row data will be refreshed and any bound columns will be updated.
-
- \return SQLRETURN
-
- \sa setRow
- getRow
- getRows
- doNext
- doPrev
- doFirst
- doLast
- doSkip
+/*!
+ \brief Prepares for a \sa doSkip.
*/
-SQLRETURN MResultRes::doSkip( qlonglong nRows )
+SQLRETURN MResultRes::doSkip_( qlonglong nRows )
{
MYODBCDbgEnter();
@@ -637,19 +620,6 @@
MYODBCDbgReturn( SQL_SUCCESS );
}
-SQLRETURN MResultRes::doGoto( qulonglong nRow )
-{
- MYODBCDbgEnter();
-
- if ( nRow )
- {
- }
-
- getAppRowDesc()->getArraySize()
-
- MYODBCDbgReturn( SQL_SUCCESS );
-}
-
/*!
\brief Downgrades cursor if it exceeds our abilities.
Modified: trunk/SDK/MYSQLPlus/Library/MResultRes.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultRes.h 2006-09-13 22:12:39 UTC (rev 543)
+++ trunk/SDK/MYSQLPlus/Library/MResultRes.h 2006-09-14 19:33:25 UTC (rev 544)
@@ -34,14 +34,8 @@
SQLRETURN doCommit();
SQLRETURN doDelete();
SQLRETURN doExecute();
- SQLRETURN doFirst( BOOLEAN bRefresh = true );
- SQLRETURN doGoto( qulonglong nRow, BOOLEAN bRefresh = true );
SQLRETURN doInsert();
- SQLRETURN doLast( BOOLEAN bRefresh = true );
- SQLRETURN doNext( BOOLEAN bRefresh = true );
SQLRETURN doPrepare( MCommand *pCommand );
- SQLRETURN doPrev( BOOLEAN bRefresh = true );
- SQLRETURN doSkip( qlonglong nRowSets, BOOLEAN bRefresh = true );
protected:
@@ -49,6 +43,36 @@
SQLRETURN doApplyCursorRestrictions();
SQLRETURN doStateRollBack( STATE nState );
+ /*!
+ \brief Prepares for a cursor call.
+
+ BUFFERED_UNBUFFERED
+
+ 1. Valid only for doNext.
+ 2. Positions MySQL client cursor (next pos only).
+ 3. Ensures that RowSet is loaded.
+
+ BUFFERED_MYSQL_PLUS
+
+ 1. Ensures that ResultSet has all rows leading up to desired
ResultSetRow loaded.
+ 2. Ensures that ResultSet has RowSet loaded from ResultSetRow.
+ 3. Increments ResultSetRows if new rows loaded.
+ 4. Sets ResultSetRowsKnown if no more rows to load.
+
+ BUFFERED_MYSQL_CLIENT
+
+ 1. Positions MySQL client cursor.
+ 2. Ensures that RowSet is loaded.
+ */
+ /*@{*/
+ SQLRETURN doFirst_();
+ SQLRETURN doGoto_( qulonglong nRow );
+ SQLRETURN doLast_();
+ SQLRETURN doNext_();
+ SQLRETURN doPrev_();
+ SQLRETURN doSkip_( qlonglong nRowSets );
+ /*@}*/
+
private:
MCommand * pCommand; /*!< the command we are supporting
*/
MYSQL_RES * pRes; /*!< current resultset as per
mysql_use_result() / mysql_store_result() */
| Thread |
|---|
| • Connector/ODBC 5 commit: r544 - trunk/SDK/MYSQLPlus/Library | pharvey | 14 Sep |