My problem (ticket 1272) is that I open multiple sqlite handles in one thread and then pass the handles to other threads to perform the work. That is:

db1 = sqlite3_open();
db2 = sqlite3_open();
pthread_create(...,db1);
pthread_create(...,db2);

While this does not appear to be disallowed by the FAQ:

> "Threadsafe" in the previous paragraph means that two or more threads can
> run SQLite at the same time on different "sqlite" structures returned
> from separate calls to sqlite_open(). It is never safe to use the same
> sqlite structure pointer simultaneously in two or more threads.

it does appear to (potentially) be invalid (when threads don't override each other). The lock structure depends on the thread that opens the database, not the thread that is currently using it. And, in my case, I end up with 2 threads sharing the same lock structure which is incorrect because they cannot override each other's locks.

The new misuse tests that were added were very helpful for identifying this. But, are the current behaviour (and tests) the "right" ones? That is, should the FAQ be updated to indicate that only the thread that calls sqlite3_open is allowed to use the structure?

Cheers,
Chris.

Reply via email to