PDA

View Full Version : SQLite thread support



adzajac
9th March 2010, 15:41
Hi

Does anybody know did SQLite driver shipped with Qt4 is build to have SQLITE_THREADSAFE=1 flag set during the compilation or not.
If yes how to and where set SQLITE_THREADSAFE=2 to recompile with multit-hreded support instead serialized threads.

Is there any possibility to use sqlite3_config( ... ) method re alter the thread support mode in Qt4.

Regards

andrey-rogozhnikov
31st May 2013, 07:47
There was no answer for long time, but the question is also important for me.

It seems that if no precompiler definitions are made during compilation of library, SQLITE_THREADSAFE will be set to 1, but I want to know it for sure.

Lesiok
31st May 2013, 09:08
But for what. From Qt doc : A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported. In addition, the third party libraries used by the QSqlDrivers can impose further restrictions on using the SQL Module in a multithreaded program. Consult the manual of your database client for more information

andrey-rogozhnikov
31st May 2013, 09:37
Of course, this point from documentation is important. I'd want to know what happens when you create different connections in different threads and try to simultaneously perform read and write operations over database. Server-based installations like PostgreSQL and others have documented rules of multithreaded access, as SQLite does too. Though there still is an ambiguity as Qt's documentation does not cover what preprocessor definitions were used to build the SQLite driver. More specifically, what value of SQLITE_THREADSAFE was used, 0, 1, or 2, or was it left default (which is 1 that enables all mutexes).

ChrisW67
31st May 2013, 11:18
src/3rdparty/sqlite.pri after running a default configure (Qt 4.8.4 on Linux):


CONFIG(release, debug|release):DEFINES *= NDEBUG
DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE
blackberry: DEFINES += SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_RTREE
wince*: DEFINES += HAVE_LOCALTIME_S=0
INCLUDEPATH += $$PWD/sqlite
SOURCES += $$PWD/sqlite/sqlite3.c

My money is on the default SQLITE_THREADSAFE = 1