SQLite: Disable mutex on connections

By default SQLite opens DB in Serialized mode, allowing connections to be used
from several threads simultaneously: https://www.sqlite.org/threadsafe.html
According to Qt documentation, database can only be used from one thread.
This change opens sqlite dabases in "Multi-thread" mode, so that one does not
pay for useless mutex locking for each DB access

Change-Id: Ife61f1a648d74c91d3b27a2ce0059d052ccc62b2
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Eric Lemanissier 2017-02-16 11:12:31 +01:00
parent 8092a01f84
commit 610a9e8f31
1 changed files with 2 additions and 0 deletions

View File

@ -700,6 +700,8 @@ bool QSQLiteDriver::open(const QString & db, const QString &, const QString &, c
if (openUriOption)
openMode |= SQLITE_OPEN_URI;
openMode |= SQLITE_OPEN_NOMUTEX;
if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) {
sqlite3_busy_timeout(d->access, timeOut);
setOpen(true);