Modified:
MYSQLPlus/MYSQLPlusLib/MResult.cpp
MYSQLPlus/MYSQLPlusLib/MResult.h
MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
MYSQLPlus/MYSQLPlusLib/MResultStmt.h
MYSQLPlus/MYSQLPlusLib/MStatement.cpp
Log:
Modified: MYSQLPlus/MYSQLPlusLib/MResult.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-05-10 17:00:47 UTC (rev 220)
+++ MYSQLPlus/MYSQLPlusLib/MResult.cpp 2006-05-10 21:51:33 UTC (rev 221)
@@ -51,6 +51,7 @@
nState = STATE_UNINITIALIZED;
bReadOnly = true;
+ bBuffered = true;
pStatement->getImpParamDesc()->doClear();
pStatement->getImpRowDesc()->doClear();
@@ -79,6 +80,12 @@
MYODBCDbgReturn3( "%d", bReadOnly );
}
+BOOLEAN MResult::isBuffered()
+{
+ MYODBCDbgEnter();
+ MYODBCDbgReturn3( "%d", bBuffered );
+}
+
BOOLEAN MResult::isValidColumn( uint nColumn )
{
BOOLEAN b;
Modified: MYSQLPlus/MYSQLPlusLib/MResult.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResult.h 2006-05-10 17:00:47 UTC (rev 220)
+++ MYSQLPlus/MYSQLPlusLib/MResult.h 2006-05-10 21:51:33 UTC (rev 221)
@@ -63,10 +63,11 @@
virtual SQLRETURN doSkip( qlonglong nRows ) = 0;
/* isers */
- BOOLEAN isReadOnly();
virtual BOOLEAN isValidColumn( uint nColumn );
virtual BOOLEAN isValidRow() = 0;
virtual BOOLEAN isValidRow( qulonglong nRow ) = 0;
+ BOOLEAN isReadOnly();
+ BOOLEAN isBuffered();
protected:
@@ -86,8 +87,10 @@
virtual SQLRETURN doStateRollBack( STATE nState ) = 0;
private:
- STATE nState; /*!< our state
*/
- BOOLEAN bReadOnly; /*!< can a caller use methods like setData() and
doAppend() */
+ STATE nState; /*!< our state
*/
+ BOOLEAN bBuffered; /*!< true causes entire resultset to get pulled to client
at execute (enabling other features) (default=true) */
+ BOOLEAN bReadOnly; /*!< true means readonly resultset (default=true)
*/
+ BOOLEAN bForwardOnly; /*!< true means we plan to scroll one row at a time
(default=true) */
};
#endif
Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-05-10 17:00:47 UTC (rev 220)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.cpp 2006-05-10 21:51:33 UTC (rev 221)
@@ -12,8 +12,6 @@
nState = STATE_UNINITIALIZED;
pbindColumns = NULL;
- nRow = 0;
- stringStatement = QString::null;
pstm = mysql_stmt_init( (MYSQL*)(pStatement->getConnection()->getMySQL()) );
if ( pstm )
@@ -70,14 +68,14 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("Resultset is read-only.") ) );
if ( !isValidRow() )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid row." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid row.") ) );
if ( !isValidColumn( nColumn ) )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid column.") ) );
// can not write this column (and it does not really exist anyway as bookmark is row
num)
if ( nColumn == 0 )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column. Bookmark column is read-only." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid column. Bookmark column is read-only.") ) );
/*! \internal
\todo
@@ -85,7 +83,7 @@
Revisit this method and see about implementing.
*/
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "setData
not supported here at this time." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, tr("setData
not supported here at this time.") ) );
}
/*!
@@ -127,12 +125,13 @@
Q_ASSERT( !pstm );
/*!
- \internal
- \todo
+ \internal MYSQL RULE
- Handle return code.
+ mysql_stmt_data_seek() has no return value and produces no errors.
*/
mysql_stmt_data_seek( pstm, nRow - 1 );
+ if ( mysql_stmt_errno( pstm ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_stmt_errno( pstm ), mysql_stmt_error( pstm ) ) );
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -190,10 +189,10 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
if ( !isValidRow() )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid row." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid row.") ) );
if ( !isValidColumn( nColumn ) )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Invalid column." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Invalid column.") ) );
if ( nColumn == 0 )
variantData = nRow; // bookmark - using nRow has limitations !!!
@@ -250,7 +249,7 @@
variantData.setValue( QByteArray( (const char *)pbind->buffer,
pbind->length_value ) );
break;
default:
- MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, "Invalid column bind data type." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, tr("Invalid column bind data type.") ) );
}
}
}
@@ -263,7 +262,7 @@
\brief This gets column data from the drivers row buffers.
\param nColumn The column we are dealing with.
- \param pDescriptorRecord This a bound ARD.
+ \param pDescriptorRecord This is a bound ARD.
\return SQLRETURN
@@ -527,12 +526,14 @@
Q_ASSERT( !pnRow );
/*!
- \internal
- \todo
+ \internal MYSQL RULE
- Handle errors.
+ mysql_stmt_num_rows() returns number of rows (0-n) and generates no
+ errors.
*/
*pnRows = mysql_stmt_num_rows( pstm );
+ if ( mysql_stmt_errno( pstm ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_stmt_errno( pstm ), mysql_stmt_error( pstm ) ) );
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -560,7 +561,7 @@
if ( isReadOnly() )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("Resultset is read-only.") ) );
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "doAppend
not supported here at this time." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doAppend not supported here at this time.") ) );
}
/*!
@@ -582,7 +583,7 @@
/* we failed to init in constructor */
if ( getState() == STATE_UNINITIALIZED )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY001, 0,
"mysql_stmt_init() failed" ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY001, 0,
tr("mysql_stmt_init() failed") ) );
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -610,7 +611,7 @@
if ( isReadOnly() )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("Resultset is read-only.") ) );
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "doDelete
not supported here at this time." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doDelete not supported here at this time.") ) );
}
/*!
@@ -645,6 +646,14 @@
if ( mysql_stmt_execute( pstm ) )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_stmt_errno( pstm ), mysql_stmt_error( pstm ) ) );
+ /*!
+ \internal MYSQLPlus RULE
+
+ We always use buffered data and other bits of logic depend upon this. In the
+ future we should make this an option and simply report failure or warning when
+ we are unable to meet the other requests with unbuffered. For example; row count
+ currently assumes we have all the data and know the real number of rows.
+ */
if ( mysql_stmt_store_result( pstm ) )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_stmt_errno( pstm ), mysql_stmt_error( pstm ) ) );
@@ -688,6 +697,8 @@
nRow = 1;
mysql_stmt_data_seek( pstm, nRow - 1 );
+ if ( mysql_stmt_errno( pstm ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000,
mysql_stmt_errno( pstm ), mysql_stmt_error( pstm ) ) );
doRefresh();
@@ -717,7 +728,7 @@
if ( isReadOnly() )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010, 0,
tr("Resultset is read-only.") ) );
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0, "doInsert
not supported here at this time." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("doInsert not supported here at this time.") ) );
}
/*!
@@ -803,8 +814,10 @@
MYODBCDbgReturn( SQL_NO_DATA );
}
- mysql_stmt_data_seek( pstm, nRow - 1 );
+ mysql_stmt_fetch( pstm );
+// mysql_stmt_data_seek( pstm, nRow - 1 );
+
doRefresh();
MYODBCDbgReturn( SQL_SUCCESS );
@@ -844,9 +857,6 @@
MYODBCDbgReturn( nReturn );
}
- /* now we are prepared */
- this->stringStatement = stringStatement;
-
MYODBCDbgReturn( SQL_SUCCESS );
}
@@ -927,7 +937,7 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
if ( nRows == 0 )
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0, "doSkip
0 records is meaningless." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0,
tr("doSkip 0 records is meaningless.") ) );
if ( !isValidRow( nRow + nRows ) )
{
@@ -987,11 +997,11 @@
case 0:
break;
case CR_INVALID_PARAMETER_NO:
- MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, "CR_INVALID_PARAMETER_NO" ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, tr("CR_INVALID_PARAMETER_NO") ) );
case CR_NO_DATA:
- MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, "CR_NO_DATA" ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, tr("CR_NO_DATA") ) );
default:
- MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, "Unknown error from mysql_stmt_fetch_column()." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend(
MDiagnostic::DIA_HY000, 0, tr("Unknown error from mysql_stmt_fetch_column().") ) );
}
}
}
@@ -1020,7 +1030,7 @@
}
/*!
- \brief Informs called whether or not the current row is a valid row.
+ \brief Informs caller whether or not the current row is a valid row.
The current row is either valid or position at 0 (invalid). When the current
row is positioned
at 0; a doNext will do same as a doFirst while a doPrev will do same as a
doLast.
@@ -1086,16 +1096,6 @@
\sa getState
*/
-
-/*
- pstm;
- pbindColumns;
- nRow = 0;
- stringStatement = QString::null;
- getImpParamDesc()->doClear();
- getImpRowDesc()->doClear();
-
-*/
SQLRETURN MResultStmt::doStateRollBack( STATE nState )
{
MYODBCDbgEnter();
@@ -1117,8 +1117,6 @@
case STATE_PREPARED:
{
- int bUpdateMaxLength = 1;
-
/* cleanup work done by doPrepare() */
if ( pbindColumns )
{
@@ -1129,9 +1127,9 @@
MYODBCC::doFree( pbindColumns[nColumn].buffer );
}
MYODBCC::doFree( pbindColumns );
+ pbindColumns = NULL;
}
- pbindColumns = NULL;
- stringStatement = QString::null;
+ getImpParamDesc()->doClear();
getImpRowDesc()->doClear();
}
setState(STATE_INITIALIZED );
@@ -1209,7 +1207,7 @@
if ( !SQL_SUCCEEDED( nReturn ) )
{
mysql_free_result( pMetaData );
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
"Failed to store field descriptor information." ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
tr("Failed to store field descriptor information.") ) );
}
/* init bind for field */
@@ -1625,7 +1623,7 @@
break;
default:
{
- MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "%1 is an unknown MYSQL column data type." ).arg( pField->type ) ) );
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY000, 0,
QString( "%1 %2" ).arg( pField->type ).arg( tr(" is an unknown MYSQL column data
type.") ) ) );
}
}
Modified: MYSQLPlus/MYSQLPlusLib/MResultStmt.h
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MResultStmt.h 2006-05-10 17:00:47 UTC (rev 220)
+++ MYSQLPlus/MYSQLPlusLib/MResultStmt.h 2006-05-10 21:51:33 UTC (rev 221)
@@ -76,15 +76,15 @@
BOOLEAN isValidRow();
BOOLEAN isValidRow( qulonglong nRow );
+ setCursorType( SQLUINTEGER nCursorType )
+
protected:
/* doers */
SQLRETURN doStateRollBack( STATE nState );
private:
- MYSQL_STMT * pstm; /*!< MySQL prepared statement
*/
- MYSQL_BIND * pbindColumns; /*!< binds for every col in res - loaded witb
call to mysql_stmt_fetch_column() as needed */
- qulonglong nRow; /*!< Current row. This is 1-based but a 0 is
valid (means before first row and after last row). */
- QString stringStatement; /*!< SQL statement as provided to doPrepare()
*/
+ MYSQL_STMT * pstm; /*!< MySQL prepared statement
*/
+ MYSQL_BIND * pbindColumns; /*!< binds for every col in res - loaded witb
call to mysql_stmt_fetch_column() as needed */
/* prepare MYSQL_BIND for a call to mysql_stmt_fetch_column() - used by SQLColBind
and SQLGetData */
// SQLRETURN doInitBindCol( MYODBC_BIND_COL *pbind, uint nColumn, SQLSMALLINT
nTargetType, SQLPOINTER pTarget, SQLINTEGER nTargetSize, SQLINTEGER *pnStrLenInd );
Modified: MYSQLPlus/MYSQLPlusLib/MStatement.cpp
===================================================================
--- MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-05-10 17:00:47 UTC (rev 220)
+++ MYSQLPlus/MYSQLPlusLib/MStatement.cpp 2006-05-10 21:51:33 UTC (rev 221)
@@ -1785,6 +1785,22 @@
case SQL_CONCUR_LOCK:
case SQL_CONCUR_ROWVER:
case SQL_CONCUR_VALUES:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
if ( nCursorSensitivity == SQL_INSENSITIVE )
nCursorSensitivity = SQL_UNSPECIFIED;
break;
@@ -1807,6 +1823,22 @@
nCursorType = SQL_CURSOR_FORWARD_ONLY;
break;
case SQL_SCROLLABLE:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
nCursorType = SQL_CURSOR_STATIC; /*! \todo see odbc spec about this rule and
improve */
break;
default:
@@ -1831,6 +1863,22 @@
nCursorType = SQL_CURSOR_STATIC;
break;
case SQL_SENSITIVE:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
if ( nConcurrency == SQL_CONCUR_READ_ONLY )
nConcurrency = SQL_CONCUR_VALUES;
break;
@@ -1872,6 +1920,22 @@
break;
case SQL_CURSOR_STATIC:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
nCursorScrollable = SQL_SCROLLABLE;
if ( nConcurrency == SQL_CONCUR_READ_ONLY )
nCursorSensitivity = SQL_INSENSITIVE;
@@ -1880,12 +1944,44 @@
break;
case SQL_CURSOR_KEYSET_DRIVEN:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
nCursorScrollable = SQL_SCROLLABLE;
if ( nConcurrency != SQL_CONCUR_READ_ONLY )
nCursorSensitivity = SQL_UNSPECIFIED;
break;
case SQL_CURSOR_DYNAMIC:
+/*!
+ \internal MYSQLPlus RULE
+
+ We only support;
+
+ nConcurrency = SQL_CONCUR_READ_ONLY
+ nCursorScrollable = SQL_NONSCROLLABLE
+ nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
+ nCursorType = SQL_CURSOR_FORWARD_ONLY
+
+ This amounts to a forward-only cursor on a read-only resultset.
+
+ \todo Expand this support.
+*/
+MYODBCDbgReturn( pDiagnostic->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+
nCursorScrollable = SQL_SCROLLABLE;
if ( nConcurrency != SQL_CONCUR_READ_ONLY )
nCursorSensitivity = SQL_SENSITIVE;
| Thread |
|---|
| • Connector/ODBC 5 commit: r221 - MYSQLPlus/MYSQLPlusLib | pharvey | 11 May |