summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp11
-rw-r--r--src/sql/kernel/qsqlquery.cpp6
2 files changed, 15 insertions, 2 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 9fba6d6fe4..8294a55633 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -322,12 +322,14 @@ bool QSQLiteResult::prepare(const QString &query)
setSelect(false);
+ const void *pzTail = NULL;
+
#if (SQLITE_VERSION_NUMBER >= 3003011)
int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
- &d->stmt, 0);
+ &d->stmt, &pzTail);
#else
int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar),
- &d->stmt, 0);
+ &d->stmt, &pzTail);
#endif
if (res != SQLITE_OK) {
@@ -335,6 +337,11 @@ bool QSQLiteResult::prepare(const QString &query)
"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",
+ "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE));
+ d->finalize();
+ return false;
}
return true;
}
diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp
index 4eb46f1790..fda6301bc0 100644
--- a/src/sql/kernel/qsqlquery.cpp
+++ b/src/sql/kernel/qsqlquery.cpp
@@ -338,6 +338,9 @@ bool QSqlQuery::isNull(int field) const
Note that the last error for this query is reset when exec() is
called.
+ For SQLite, the query string can contain only one statement at a time.
+ If more than one statements is give, the function returns false.
+
Example:
\snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 34
@@ -887,6 +890,9 @@ void QSqlQuery::clear()
syntactically wrong query succeeds, but every consecutive exec()
will fail.
+ For SQLite, the query string can contain only one statement at a time.
+ If more than one statements are give, the function returns false.
+
Example:
\snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 9