Modified:
trunk/SDK/MYSQLPlus/Library/MResult.h
trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp
Log:
- more work for implementing forward-only, read-only block/noblock cursor support
Modified: trunk/SDK/MYSQLPlus/Library/MResult.h
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResult.h 2006-09-02 00:03:24 UTC (rev 510)
+++ trunk/SDK/MYSQLPlus/Library/MResult.h 2006-09-02 06:04:16 UTC (rev 511)
@@ -75,7 +75,7 @@
};
/*!
- \brief Result-set.
+ \brief ResultSet abstraction.
This is the base class (pure virtual) for a result-set. The problem this
addresses is the fact that we can have a resultset generated in a variety
@@ -83,11 +83,67 @@
Notice that we have to support row and set based interaction. The most common
interaction is for the app to request a result-set (set based operation)
- using SQLExecute() but then to operate on the result-set using row based
- interactions - this is what we support here. This does not support such
things
- as block cursors. Block cursor support is layered upon our functionality here
- find
- that in MStatement.
+ using doExecute() but then to operate on the result-set using row based
+ interactions.
+ There is loose coupling between MResult and MStatement - this is deliberate
+ and should be improved upon.
+
+ Results
+ -------
+
+ There are two different types of results;
+
+ 1. row count - we only have a row count (ie command was an INSERT or such)
+ 2. resultset - we have 1-n columns and 0-n rows (ie command was a SELECT
or such)
+
+ ResultSet
+ ---------
+
+ A resultset contains exactly one Cursor/RowSet. There are two different
types;
+
+ 1. single row - the Cursor/RowSet contains 1 row
+ 2. block - the Cursor/RowSet contains more than 1 row
+
+ Important ResultSet attributes are;
+
+ 1. cursor type
+ 2. read-only/updateable
+
+ Cursor
+ ------
+
+ A cursor is a RowSet (1-n rows) which can be moved about the ResultSet.
+
+ Cursor types;
+
+ 1. forward-only - can only scroll forward
+ 2. scrollable - can scroll forward and backward
+ 3. block - has more than one row
+
+ The cursor can be moved using methods like; doNext, doPrev.
+
+ RowSet
+ ------
+
+ A RowSet is a cursor but because it may contain more than 1 row - its has its
own
+ cursor (which is always 1 row). The RowSet cursor is called a RowSetRow and
its the
+ current row in the RowSet.
+
+ RowSetSize is the max number of rows in the RowSet. The RowSet may be
truncated when
+ it overlaps the end of the ResultSet. RowSetRows is the actual number of rows
+ available in the RowSet.
+
+ A RowSet exists, primarly, to provide a means to optimize data access for
screen
+ applications.
+
+ RowSetRow
+ ---------
+
+ The RowSetRow is the current row in the RowSet. When the Cursor/RowSet is
moved
+ the RowSetRow is always set to the first row in the RowSet. getData/setData
can be
+ used to get/set column data for the RowSetRow. RowSetRow is moved using
setRowSetRow.
+
\sa MResultPlus
MResultRes
MResultStmt
@@ -111,6 +167,7 @@
/* setters */
virtual SQLRETURN setData( uint nColumn, const QVariant &variantData ) = 0;
virtual SQLRETURN setRowSetRow( SQLUSMALLINT nRow ) = 0; /*!<
Set position in rowset. */
+ virtual SQLRETURN setRowSetSize( SQLUINTEGER nRowSetSize = 1 );
/* getters */
STATE getState();
@@ -118,9 +175,12 @@
virtual SQLRETURN getColumns( uint *pnColumns ) = 0;
virtual SQLRETURN getData( SQLUSMALLINT nColumn, QVariant &variantData ) =
0;
virtual SQLRETURN getData( SQLUSMALLINT nColumn, SQLSMALLINT nTargetType,
SQLPOINTER pTargetValue, SQLINTEGER nBufferLength, SQLINTEGER *pnLength, SQLINTEGER
*pnIndicator );
- virtual qulonglong getRowSet() = 0; /*!< Current row in
resultset. */
- virtual SQLUSMALLINT getRowSetRow() = 0; /*!< Current row in
rowset. */
- virtual SQLRETURN getRows( qulonglong *pnRows ) = 0; /*!< Get number of
rows in the resultset. */
+ virtual qulonglong getRowSet() = 0; /*!< Row, in
resultset, where rowset begins. \sa getResultSetRow */
+ virtual SQLUSMALLINT getRowSetRow() = 0; /*!< Current
row in rowset. */
+ virtual SQLUINTEGER getRowSetRows() = 0; /*!< Number of
rows in rowset (max=getRowSetSize). */
+ virtual SQLUINTEGER getRowSetSize(); /*!< Max
number of rows in rowset (rowset trunc. if part past resultset). */
+ virtual qulonglong getResultSetRow() = 0; /*!< Current
row in resultset. \sa getRowSet */
+ virtual SQLRETURN getResultSetRows( qulonglong *pnRows ) = 0; /*!< Number of
resultset rows. */
/* doers */
virtual SQLRETURN doPrepare( MCommand *pCommand ) = 0; /*!< Prepare the given
command. */
@@ -165,7 +225,6 @@
MDescriptor * getAppRowDesc();
MDescriptor * getImpParamDesc();
MDescriptor * getImpRowDesc();
- SQLUINTEGER getRowSetSize();
/* support for getData: this is called when target C type is SQL_C_DEFAULT (derive
type from IRD) */
SQLRETURN setGetDataDefault();
Modified: trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp 2006-09-02 00:03:24 UTC (rev 510)
+++ trunk/SDK/MYSQLPlus/Library/MResultPlus.cpp 2006-09-02 06:04:16 UTC (rev 511)
@@ -101,16 +101,22 @@
if ( getState() < STATE_EXECUTED )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
- if ( !isValidCursor() )
+ if ( !isValidRowSetRow() )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid row." ) );
if ( !isValidColumn( nColumn ) )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column." ) );
+ /*!
+ \internal MYSQLPlus RULE
+
+ Read-only resultsets use row number as bookmark. This only works for resultsets
+ where number of rows does not exceed capacity of qulonglong.
+ */
if ( nColumn == 0 )
- variantData = nRow; // bookmark is row num - obvious limitations apply
+ variantData = getRow();
else
- variantData = listResults[ nRow - 1 ][ nColumn - 1 ];
+ variantData = listResults[ getRow() ][ nColumn - 1 ];
MYODBCDbgReturn( SQL_SUCCESS );
}
| Thread |
|---|
| • Connector/ODBC 5 commit: r511 - trunk/SDK/MYSQLPlus/Library | pharvey | 2 Sep |