1.Dd January 24, 2024 2.Dt SQLITE3_THREADSAFE 3 3.Os 4.Sh NAME 5.Nm sqlite3_threadsafe 6.Nd test to see if the library is threadsafe 7.Sh SYNOPSIS 8.In sqlite3.h 9.Ft int 10.Fo sqlite3_threadsafe 11.Fa "void" 12.Fc 13.Sh DESCRIPTION 14The sqlite3_threadsafe() function returns zero if and only if SQLite 15was compiled with mutexing code omitted due to the SQLITE_THREADSAFE 16compile-time option being set to 0. 17.Pp 18SQLite can be compiled with or without mutexes. 19When the SQLITE_THREADSAFE C preprocessor macro is 201 or 2, mutexes are enabled and SQLite is threadsafe. 21When the SQLITE_THREADSAFE macro is 0, the mutexes 22are omitted. 23Without the mutexes, it is not safe to use SQLite concurrently from 24more than one thread. 25.Pp 26Enabling mutexes incurs a measurable performance penalty. 27So if speed is of utmost importance, it makes sense to disable the 28mutexes. 29But for maximum safety, mutexes should be enabled. 30The default behavior is for mutexes to be enabled. 31.Pp 32This interface can be used by an application to make sure that the 33version of SQLite that it is linking against was compiled with the 34desired setting of the SQLITE_THREADSAFE macro. 35.Pp 36This interface only reports on the compile-time mutex setting of the 37SQLITE_THREADSAFE flag. 38If SQLite is compiled with SQLITE_THREADSAFE=1 or =2 then mutexes are 39enabled by default but can be fully or partially disabled using a call 40to 41.Fn sqlite3_config 42with the verbs SQLITE_CONFIG_SINGLETHREAD, 43SQLITE_CONFIG_MULTITHREAD, or SQLITE_CONFIG_SERIALIZED. 44The return value of the sqlite3_threadsafe() function shows only the 45compile-time setting of thread safety, not any run-time changes to 46that setting made by sqlite3_config(). 47In other words, the return value from sqlite3_threadsafe() is unchanged 48by calls to sqlite3_config(). 49.Pp 50See the threading mode documentation for additional information. 51.Sh IMPLEMENTATION NOTES 52These declarations were extracted from the 53interface documentation at line 221. 54.Bd -literal 55SQLITE_API int sqlite3_threadsafe(void); 56.Ed 57.Sh SEE ALSO 58.Xr sqlite3_config 3 , 59.Xr SQLITE_CONFIG_SINGLETHREAD 3 60