Modified:
trunk/SDK/MYSQLPlus/Library/MStatement.cpp
Log:
- more work for implementing forward-only, read-only block/noblock cursor support
Modified: trunk/SDK/MYSQLPlus/Library/MStatement.cpp
===================================================================
--- trunk/SDK/MYSQLPlus/Library/MStatement.cpp 2006-08-31 22:46:54 UTC (rev 504)
+++ trunk/SDK/MYSQLPlus/Library/MStatement.cpp 2006-09-01 00:26:25 UTC (rev 505)
@@ -1725,14 +1725,52 @@
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY010 ) );
/*!
- \internal
- \todo
+ \internal ODBC RULE
- This is what C/ODBC v3 does - we need to implement more here.
+ The Operation argument was SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or
SQL_DELETE_BY_BOOKMARK,
+ and the SQL_ATTR_CONCURRENCY statement attribute was set to SQL_CONCUR_READ_ONLY.
*/
- if ( nOperation == SQL_ADD )
- MYODBCDbgReturn( setPos( 0, SQL_ADD, SQL_LOCK_NO_CHANGE ) );
+ if ( nOperation == SQL_ADD || nOperation == SQL_UPDATE_BY_BOOKMARK || nOperation ==
SQL_DELETE_BY_BOOKMARK )
+ {
+ if ( getConcurrency() == SQL_CONCUR_READ_ONLY )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
+ }
+ /*!
+ \internal ODBC RULE
+
+ The Operation argument was SQL_DELETE_BY_BOOKMARK, SQL_FETCH_BY_BOOKMARK, or
+ SQL_UPDATE_BY_BOOKMARK, and the bookmark column was not bound or the
+ SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF.
+ */
+ if ( nOperation == SQL_FETCH_BY_BOOKMARK || nOperation == SQL_UPDATE_BY_BOOKMARK ||
nOperation == SQL_DELETE_BY_BOOKMARK )
+ {
+ /* bookmarks supported and enabled? */
+ if ( getConnection()->getInfoBookmarkPersistence() == 0 || getUseBookmarks()
== SQL_UB_OFF )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
+ /* bookmark column bound? */
+ MDescriptorRecord *pRecord = getImpRowDesc()->getRecord( 0 );
+ if ( !pRecord || !pRecord->getDataPtr() )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
+ }
+
+ switch ( nOperation )
+ {
+ case SQL_ADD:
+ case SQL_UPDATE_BY_BOOKMARK:
+ case SQL_DELETE_BY_BOOKMARK:
+ case SQL_FETCH_BY_BOOKMARK:
+ break;
+
+ default:
+ /*!
+ \internal ODBC RULE (DM)
+
+ The value specified for the Operation argument was invalid.
+ */
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
+ }
+
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_IM001 ) );
}
@@ -5376,33 +5414,57 @@
if ( getState() >= STATE_S2 )
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY011 ) );
+ /* what do we support? */
+ SQLUINTEGER nCursorAttributes2 = 0;
+
+ switch ( nCursorType )
+ {
+ case SQL_CURSOR_FORWARD_ONLY:
+ nCursorAttributes2 =
getConnection()->getInfoForwardOnlyCursorAttributes2();
+ break;
+ case SQL_CURSOR_STATIC:
+ nCursorAttributes2 = getConnection()->getInfoStaticCursorAttributes2();
+ break;
+ case SQL_CURSOR_KEYSET_DRIVEN:
+ nCursorAttributes2 = getConnection()->getInfoKeysetCursorAttributes2();
+ break;
+ case SQL_CURSOR_DYNAMIC:
+ nCursorAttributes2 = getConnection()->getInfoDynamicCursorAttributes2();
+ break;
+ }
+
+ /* set it */
switch ( nConcurrency )
{
case SQL_CONCUR_READ_ONLY:
+ /* do we support this feature? */
+ if ( nCursorAttributes2 == 0 || !( nCursorAttributes2 &
SQL_CA2_READ_ONLY_CONCURRENCY ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CONCUR_READ_ONLY not supported for cursor type.") ) );
+
nCursorSensitivity = SQL_INSENSITIVE;
break;
+
case SQL_CONCUR_LOCK:
+ /* do we support this feature? */
+ if ( nCursorAttributes2 == 0 || !( nCursorAttributes2 &
SQL_CA2_LOCK_CONCURRENCY ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CONCUR_LOCK not supported for cursor type.") ) );
+ break;
+
case SQL_CONCUR_ROWVER:
+ /* do we support this feature? */
+ if ( nCursorAttributes2 == 0 || !( nCursorAttributes2 &
SQL_CA2_OPT_ROWVER_CONCURRENCY ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CONCUR_ROWVER not supported for cursor type.") ) );
+ break;
+
case SQL_CONCUR_VALUES:
-/*!
- \internal MYSQLPlus RULE
+ /* do we support this feature? */
+ if ( nCursorAttributes2 == 0 || !( nCursorAttributes2 &
SQL_CA2_OPT_VALUES_CONCURRENCY ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CONCUR_VALUES not supported for cursor type.") ) );
- 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( getDiagnostic()->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;
+
default:
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
}
@@ -5457,30 +5519,59 @@
{
case SQL_UNSPECIFIED:
break;
+
case SQL_INSENSITIVE:
- nConcurrency = SQL_CONCUR_READ_ONLY;
- nCursorType = SQL_CURSOR_STATIC;
- break;
- case SQL_SENSITIVE:
-/*!
- \internal MYSQLPlus RULE
+ /* do we support feature? */
+ if ( !( getConnection()->getInfoCursorSensitivity() & SQL_INSENSITIVE
) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_INSENSITIVE not supported.") ) );
- We only support;
+ nConcurrency = SQL_CONCUR_READ_ONLY;
- nConcurrency = SQL_CONCUR_READ_ONLY
- nCursorScrollable = SQL_NONSCROLLABLE
- nCursorSensitivity = SQL_UNSPECIFIED/SQL_INSENSITIVE
- nCursorType = SQL_CURSOR_FORWARD_ONLY
+ /* spec says to switch cursor type to static - but do we support static? */
+ if ( getConnection()->getInfoScrollOptions() & SQL_SO_STATIC )
+ nCursorType = SQL_CURSOR_STATIC;
+ else
+ {
+ nCursorType = SQL_CURSOR_FORWARD_ONLY;
+ getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0,
tr("SQL_CURSOR_STATIC not supported - using SQL_CURSOR_FORWARD_ONLY.") ) );
+ }
+ break;
- This amounts to a forward-only cursor on a read-only resultset.
+ case SQL_SENSITIVE:
+ /* do we support feature? */
+ if ( !( getConnection()->getInfoCursorSensitivity() & SQL_SENSITIVE )
)
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_INSENSITIVE not supported.") ) );
- \todo Expand this support.
-*/
-MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0, tr("Can only
provide a forward-only cursor on a read-only resultset.") ) );
+ /* spec says to switch concurrency to values - but do we support values? */
+ if ( nConcurrency != SQL_CONCUR_VALUES )
+ {
+ SQLUINTEGER nCursorAttributes2 = 0;
- if ( nConcurrency == SQL_CONCUR_READ_ONLY )
- nConcurrency = SQL_CONCUR_VALUES;
+ switch ( nCursorType )
+ {
+ case SQL_CURSOR_FORWARD_ONLY:
+ nCursorAttributes2 =
getConnection()->getInfoForwardOnlyCursorAttributes2();
+ break;
+ case SQL_CURSOR_STATIC:
+ nCursorAttributes2 =
getConnection()->getInfoStaticCursorAttributes2();
+ break;
+ case SQL_CURSOR_KEYSET_DRIVEN:
+ nCursorAttributes2 =
getConnection()->getInfoKeysetCursorAttributes2();
+ break;
+ case SQL_CURSOR_DYNAMIC:
+ nCursorAttributes2 =
getConnection()->getInfoDynamicCursorAttributes2();
+ break;
+ }
+ if ( nCursorAttributes2 && ( nCursorAttributes2 &
SQL_CA2_OPT_VALUES_CONCURRENCY ) )
+ nConcurrency = SQL_CONCUR_VALUES;
+ else
+ {
+ nConcurrency = SQL_CONCUR_READ_ONLY;
+ getDiagnostic()->doAppend( MDiagnostic::DIA_01000, 0,
tr("SQL_CONCUR_VALUES not supported - using SQL_CONCUR_READ_ONLY.") ) );
+ }
+ }
break;
+
default:
MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HY092 ) );
}
@@ -5515,26 +5606,17 @@
switch ( nCursorType )
{
case SQL_CURSOR_FORWARD_ONLY:
+ /* sanity check support for cursor type (although this one must be supported)
*/
+ if ( !( getConnection()->getInfoScrollOptions() & SQL_SO_FORWARD_ONLY
) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CURSOR_FORWARD_ONLY not supported.") ) );
nCursorScrollable = SQL_NONSCROLLABLE;
break;
case SQL_CURSOR_STATIC:
-/*!
- \internal MYSQLPlus RULE
+ /* do we support cursor type? */
+ if ( !( getConnection()->getInfoScrollOptions() & SQL_SO_STATIC ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CURSOR_STATIC not supported.") ) );
- 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( getDiagnostic()->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;
@@ -5543,44 +5625,20 @@
break;
case SQL_CURSOR_KEYSET_DRIVEN:
-/*!
- \internal MYSQLPlus RULE
+ /* do we support cursor type? */
+ if ( !( getConnection()->getInfoScrollOptions() & SQL_SO_KEYSET_DRIVEN
) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CURSOR_KEYSET_DRIVEN not supported.") ) );
- 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( getDiagnostic()->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
+ /* do we support cursor type? */
+ if ( !( getConnection()->getInfoScrollOptions() & SQL_SO_DYNAMIC ) )
+ MYODBCDbgReturn( getDiagnostic()->doAppend( MDiagnostic::DIA_HYC00, 0,
tr("SQL_CURSOR_DYNAMIC not supported.") ) );
- 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( getDiagnostic()->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: r505 - trunk/SDK/MYSQLPlus/Library | pharvey | 1 Sep |