summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers/sqlite/qsql_sqlite.cpp
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2015-11-25 22:26:57 +0100
committerMark Brand <mabrand@mabrand.nl>2015-12-09 07:32:32 +0000
commit371c2e478604af3e992d26f10ed755a86e166380 (patch)
tree5a2baed852def13764002f2cc6961bef151d98e8 /src/sql/drivers/sqlite/qsql_sqlite.cpp
parenta5cd0818794049ac5568d46c6301b188eb3d6623 (diff)
qsql_sqlite and qsql_sqlite2: don't hold driver data in result
Change-Id: Ia4f6adc6daaea97ac06246e9d01c6561de1227ea Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/sql/drivers/sqlite/qsql_sqlite.cpp')
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 5f6ccf3990..c7086e1777 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -150,8 +150,6 @@ public:
void initColumns(bool emptyResultset);
void finalize();
- sqlite3 *access;
-
sqlite3_stmt *stmt;
bool skippedStatus; // the status of the fetchNext() that's skipped
@@ -326,7 +324,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
// SQLITE_ERROR is a generic error code and we must call sqlite3_reset()
// to get the specific error message.
res = sqlite3_reset(stmt);
- q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult",
+ q->setLastError(qMakeError(drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to fetch row"), QSqlError::ConnectionError, res));
q->setAt(QSql::AfterLastRow);
return false;
@@ -334,7 +332,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
case SQLITE_BUSY:
default:
// something wrong, don't get col info, but still return false
- q->setLastError(qMakeError(access, QCoreApplication::translate("QSQLiteResult",
+ q->setLastError(qMakeError(drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to fetch row"), QSqlError::ConnectionError, res));
sqlite3_reset(stmt);
q->setAt(QSql::AfterLastRow);
@@ -347,7 +345,6 @@ QSQLiteResult::QSQLiteResult(const QSQLiteDriver* db)
: QSqlCachedResult(*new QSQLiteResultPrivate(this, db))
{
Q_D(QSQLiteResult);
- d->access = d->drv_d_func()->access;
const_cast<QSQLiteDriverPrivate*>(d->drv_d_func())->results.append(this);
}
@@ -383,7 +380,7 @@ bool QSQLiteResult::prepare(const QString &query)
const void *pzTail = NULL;
#if (SQLITE_VERSION_NUMBER >= 3003011)
- int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
+ int res = sqlite3_prepare16_v2(d->drv_d_func()->access, query.constData(), (query.size() + 1) * sizeof(QChar),
&d->stmt, &pzTail);
#else
int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
@@ -391,12 +388,12 @@ bool QSQLiteResult::prepare(const QString &query)
#endif
if (res != SQLITE_OK) {
- setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult",
+ setLastError(qMakeError(d->drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to execute statement"), QSqlError::StatementError, res));
d->finalize();
return false;
} else if (pzTail && !QString(reinterpret_cast<const QChar *>(pzTail)).trimmed().isEmpty()) {
- setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult",
+ setLastError(qMakeError(d->drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE));
d->finalize();
return false;
@@ -417,7 +414,7 @@ bool QSQLiteResult::exec()
int res = sqlite3_reset(d->stmt);
if (res != SQLITE_OK) {
- setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult",
+ setLastError(qMakeError(d->drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to reset statement"), QSqlError::StatementError, res));
d->finalize();
return false;
@@ -477,7 +474,7 @@ bool QSQLiteResult::exec()
}
}
if (res != SQLITE_OK) {
- setLastError(qMakeError(d->access, QCoreApplication::translate("QSQLiteResult",
+ setLastError(qMakeError(d->drv_d_func()->access, QCoreApplication::translate("QSQLiteResult",
"Unable to bind parameters"), QSqlError::StatementError, res));
d->finalize();
return false;
@@ -513,14 +510,14 @@ int QSQLiteResult::size()
int QSQLiteResult::numRowsAffected()
{
Q_D(const QSQLiteResult);
- return sqlite3_changes(d->access);
+ return sqlite3_changes(d->drv_d_func()->access);
}
QVariant QSQLiteResult::lastInsertId() const
{
Q_D(const QSQLiteResult);
if (isActive()) {
- qint64 id = sqlite3_last_insert_rowid(d->access);
+ qint64 id = sqlite3_last_insert_rowid(d->drv_d_func()->access);
if (id)
return id;
}