diff options
author | Bill King <bill.king@nokia.com> | 2009-12-07 23:04:03 (GMT) |
---|---|---|
committer | Bill King <bill.king@nokia.com> | 2009-12-07 23:04:03 (GMT) |
commit | 12b032ca7c79955f03f744bdb8f7b0d60e222e40 (patch) | |
tree | ecdbf6e63fa2b2c507337c102f597c0462d78117 /src | |
parent | 0a4f8a73165da5ec274409dffa1de921421d9bb1 (diff) | |
download | Qt-12b032ca7c79955f03f744bdb8f7b0d60e222e40.zip Qt-12b032ca7c79955f03f744bdb8f7b0d60e222e40.tar.gz Qt-12b032ca7c79955f03f744bdb8f7b0d60e222e40.tar.bz2 |
Proper fix for QTBUG-6421
fixes setForwardOnly() for both OCI and SQLite
Task-number: QTBUG-6421
Reviewed-by: Justin McPherson
Diffstat (limited to 'src')
-rw-r--r-- | src/sql/drivers/sqlite/qsql_sqlite.cpp | 17 | ||||
-rw-r--r-- | src/sql/kernel/qsqlcachedresult.cpp | 5 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 8355de2..c62f15c 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -122,14 +122,14 @@ public: sqlite3_stmt *stmt; - uint skippedStatus: 1; // the status of the fetchNext() that's skipped - uint skipRow: 1; // skip the next fetchNext()? - uint utf8: 1; + bool skippedStatus; // the status of the fetchNext() that's skipped + bool skipRow; // skip the next fetchNext()? QSqlRecord rInf; + QVector<QVariant> firstRow; }; QSQLiteResultPrivate::QSQLiteResultPrivate(QSQLiteResult* res) : q(res), access(0), - stmt(0), skippedStatus(false), skipRow(false), utf8(false) + stmt(0), skippedStatus(false), skipRow(false) { } @@ -189,10 +189,17 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i // already fetched Q_ASSERT(!initialFetch); skipRow = false; + for(int i=0;i<firstRow.count();i++) + values[i]=firstRow[i]; return skippedStatus; } skipRow = initialFetch; + if(initialFetch) { + firstRow.clear(); + firstRow.resize(sqlite3_column_count(stmt)); + } + if (!stmt) { q->setLastError(QSqlError(QCoreApplication::translate("QSQLiteResult", "Unable to fetch row"), QCoreApplication::translate("QSQLiteResult", "No query"), QSqlError::ConnectionError)); @@ -399,7 +406,7 @@ bool QSQLiteResult::exec() "Parameter count mismatch"), QString(), QSqlError::StatementError)); return false; } - d->skippedStatus = d->fetchNext(cache(), 0, true); + d->skippedStatus = d->fetchNext(d->firstRow, 0, true); if (lastError().isValid()) { setSelect(false); setActive(false); diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index b4a9241..2e4d19e 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -278,6 +278,11 @@ bool QSqlCachedResult::cacheNext() if (d->atEnd) return false; + if(isForwardOnly()) { + d->cache.clear(); + d->cache.resize(d->colCount); + } + if (!gotoNext(d->cache, d->nextIndex())) { d->revertLast(); d->atEnd = true; |