xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_threadsafe.3 (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1.Dd December 19, 2018
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.Ft int
9.Fo sqlite3_threadsafe
10.Fa "void"
11.Fc
12.Sh DESCRIPTION
13The sqlite3_threadsafe() function returns zero if and only if SQLite
14was compiled with mutexing code omitted due to the SQLITE_THREADSAFE
15compile-time option being set to 0.
16.Pp
17SQLite can be compiled with or without mutexes.
18When the SQLITE_THREADSAFE C preprocessor macro is
191 or 2, mutexes are enabled and SQLite is threadsafe.
20When the SQLITE_THREADSAFE macro is 0, the mutexes
21are omitted.
22Without the mutexes, it is not safe to use SQLite concurrently from
23more than one thread.
24.Pp
25Enabling mutexes incurs a measurable performance penalty.
26So if speed is of utmost importance, it makes sense to disable the
27mutexes.
28But for maximum safety, mutexes should be enabled.
29The default behavior is for mutexes to be enabled.
30.Pp
31This interface can be used by an application to make sure that the
32version of SQLite that it is linking against was compiled with the
33desired setting of the SQLITE_THREADSAFE macro.
34.Pp
35This interface only reports on the compile-time mutex setting of the
36SQLITE_THREADSAFE flag.
37If SQLite is compiled with SQLITE_THREADSAFE=1 or =2 then mutexes are
38enabled by default but can be fully or partially disabled using a call
39to sqlite3_config() with the verbs SQLITE_CONFIG_SINGLETHREAD,
40SQLITE_CONFIG_MULTITHREAD, or SQLITE_CONFIG_SERIALIZED.
41The return value of the sqlite3_threadsafe() function shows only the
42compile-time setting of thread safety, not any run-time changes to
43that setting made by sqlite3_config().
44In other words, the return value from sqlite3_threadsafe() is unchanged
45by calls to sqlite3_config().
46.Pp
47See the threading mode documentation for additional information.
48.Sh SEE ALSO
49.Xr sqlite3_config 3 ,
50.Xr SQLITE_CONFIG_SINGLETHREAD 3
51