Monthly Archives: October 2010
If your application is using SQLite, you may be assuming it is always compiled thread-safe, but this is not true. It will only be compiled thread-safe (with proper mutexes enabled) if the SQLITE_THREADSAFE preprocessor macro is set to 1 (serialized) or 2 (multi-threaded) (1/serialized is the default if not explicitly stated). If SQLITE_THREADSAFE is set to 0 during compilation of SQLite, it will not be thread-safe. Also note that if compiled thread-safe (1 or 2), the thread-safety mode (serialized or multi-threaded) can later be changed in runtime. See SQLite and Multiple Threads for more information.
SQLite provides the sqlite3_threadsafe() method to check whether the library was compiled thread-safe, but if your application really needs a thread-safe SQLite, you don’t want to check it during runtime. Thus, I wrote a small m4 macro that you can use in your configure.ac to check it when running ./configure
Just add this file in your m4 directory:
And then, in your configure.ac:
if test "x$ax_cv_sqlite_threadsafe" != "xyes"; then
AC_MSG_ERROR([sqlite3 is not compiled thread-safe])