diff options
author | Bill King <bill.king@nokia.com> | 2009-09-30 00:38:49 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-09-30 00:38:49 (GMT) |
commit | d6bbfac77ac5b9fa0933f07d803248eb0cfbefc5 (patch) | |
tree | ed8684f8bca64a91b9bd111ef0370212a90e4729 /src/sql/drivers | |
parent | 8c3bf71e6fcbcfb21b9574e25cfdb00614a0c68d (diff) | |
download | Qt-d6bbfac77ac5b9fa0933f07d803248eb0cfbefc5.zip Qt-d6bbfac77ac5b9fa0933f07d803248eb0cfbefc5.tar.gz Qt-d6bbfac77ac5b9fa0933f07d803248eb0cfbefc5.tar.bz2 |
(ODBC) Better fix for readonly result set
This fixes an issue where a forwardonly result set would force
forwardonly on the next query, despite what the user had explicitly set.
Reviewed-by: Justin McPherson
Diffstat (limited to 'src/sql/drivers')
-rw-r--r-- | src/sql/drivers/odbc/qsql_odbc.cpp | 17 | ||||
-rw-r--r-- | src/sql/drivers/odbc/qsql_odbc.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 7cf5e8b..ff9458b 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -127,7 +127,7 @@ class QODBCPrivate { public: QODBCPrivate(QODBCDriverPrivate *dpp) - : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp) + : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp), userForwardOnly(false) { unicode = false; } @@ -148,6 +148,7 @@ public: int disconnectCount; bool hasSQLFetchScroll; QODBCDriverPrivate *driverPrivate; + bool userForwardOnly; bool isStmtHandleValid(const QSqlDriver *driver); void updateStmtHandleState(const QSqlDriver *driver); @@ -848,7 +849,7 @@ bool QODBCResult::reset (const QString& query) d->updateStmtHandleState(driver()); - if (isForwardOnly()) { + if (d->userForwardOnly) { r = SQLSetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, @@ -885,7 +886,7 @@ bool QODBCResult::reset (const QString& query) SQLINTEGER isScrollable, bufferLength; r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength); if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) - setForwardOnly(isScrollable==SQL_NONSCROLLABLE); + QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE); SQLSMALLINT count; SQLNumResultCols(d->hStmt, &count); @@ -1194,7 +1195,7 @@ bool QODBCResult::prepare(const QString& query) d->updateStmtHandleState(driver()); - if (isForwardOnly()) { + if (d->userForwardOnly) { r = SQLSetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_FORWARD_ONLY, @@ -1508,7 +1509,7 @@ bool QODBCResult::exec() SQLINTEGER isScrollable, bufferLength; r = SQLGetStmtAttr(d->hStmt, SQL_ATTR_CURSOR_SCROLLABLE, &isScrollable, SQL_IS_INTEGER, &bufferLength); if(r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) - setForwardOnly(isScrollable==SQL_NONSCROLLABLE); + QSqlResult::setForwardOnly(isScrollable==SQL_NONSCROLLABLE); SQLSMALLINT count; SQLNumResultCols(d->hStmt, &count); @@ -1639,6 +1640,12 @@ void QODBCResult::virtual_hook(int id, void *data) } } +void QODBCResult::setForwardOnly(bool forward) +{ + d->userForwardOnly = forward; + QSqlResult::setForwardOnly(forward); +} + //////////////////////////////////////// diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h index d8a3b69..8bd7660 100644 --- a/src/sql/drivers/odbc/qsql_odbc.h +++ b/src/sql/drivers/odbc/qsql_odbc.h @@ -100,6 +100,7 @@ public: bool exec(); QVariant handle() const; + virtual void setForwardOnly(bool forward); protected: bool fetchNext(); |