Dear all,

I have a (probably) very basic question regarding the usage of SQLite in an
multithreaded environment.

I use a compiled version of SQLite with SQLITE_THREADSAFE 0. Inside my
application exists one thread that is the exclusive user of the SQLite
interface. So from my point of view I am using SQLite as if it was used in
a single threaded application.

The documentation regarding threadsavety reads:

SQLite support three different threading modes:

   1.

   *Single-thread*. In this mode, all mutexes are disabled and SQLite is
   unsafe to use in more than a single thread at once.
   2.

   *Multi-thread*. In this mode, SQLite can be safely used by multiple
   threads provided that no single database connection is used simultaneously
   in two or more threads.
   3.

   *Serialized*. In serialized mode, SQLite can be safely used by multiple
   threads with no restriction.


So the first question would be: Is my understanding correct that if i only
use SQLite from one exclusive thread SQLITE_THREADSAFE 0 is save to use?

I am asking because due to a unrelated bug in my application I had switched
from using strerror to the threadsafe variant strerror_r. During this
change I noticed that SQLite uses strerror if it is compiled with
SQLITE_THREADSAFE 0.

Given the wording above, shouldn't SQLite use strerror_r? Am I missing
something? Should (1) only be used for single threaded applications? If yes
maybe the wording should be updated to reflect this explicitly.

Your help is very much appreciated.

Cheers
Kai

Reply via email to