DLL version

  Sqlite3.3.17

 

The os is windows

 

After the last query of sqlite3_step

 

I decided to so some more tests, with threads, if synchronized properly,
it seems that you can use more than one thread without any problem as
long as 

Sqlite3_finalize is called is this correct?

 

Please note that this is a very simple query being executed :  "select *
from threads where id = 1"

 

Imagine in the following scenarios both threads are executing
simultaneously and will lock on the global critical section (so they are
synchronized)

Using the same DB handle.

 

Scenario 1

 

THREAD1                                                       THREAD2

 

LockGlobalCriticalSection
LockGlobalCriticalSection

Sqlite3_prepare
Sqlite3_prepare

Sqlite3_step
Sqlite3_step    <--------------------   SQLITE_MISUSE: library routine
called out of sequence here

Sqlite3_reset
Sqlite3_reset 

UnLockGlobalCriticalSection
UnLockGlobalCriticalSection

 

// The following code works fine though

 

THREAD1                                                       THREAD2

 

LockGlobalCriticalSection
LockGlobalCriticalSection

Sqlite3_prepare
Sqlite3_prepare

Sqlite3_step
Sqlite3_step    

Sqlite3_finalize
Sqlite3_finalize 

UnLockGlobalCriticalSection
UnLockGlobalCriticalSection

 

 

If my tests are correct it is not possible to retain a prepared
statement across threads. And has to be reprepared each time ??

 

 

 

 

 

 

 

 

 

Reply via email to