On Mar 7, 2009, at 1:31 AM, Shawn Wilsher wrote:

> Hey all,
>
> I've been looking online for a bit trying to establish what  
> protections, if
> any, are associated with sqlite3_stmt objects.  It's clearly  
> documented that
> sqlite3 objects' access is serialized across threads, but I cannot  
> find
> anything about sqlite3_stmt.  I don't actually care either way, but if
> SQLite protects it internally, I don't want to add additional  
> overhead by
> protecting it myself.

Each database connection (sqlite3) has associated with it a single
mutex. Many of the operations on an sqlite3_step* object are protected
internally by this mutex (i.e. sqlite3_step()). But some are not,
especially the data access functions like sqlite3_data_count() etc.

Accessing values using the sqlite3_column_XXX() API is nearly  
threadsafe.
If some other thread calls sqlite3_step() to advance the statement while
the first thread is calling sqlite3_column_XXX(), then you could  
conceivably
get a problem. But multiple threads using the sqlite3_column_XXX()  
functions
is safe.

So I suppose the only correct answer is "no, they are not threadsafe
objects".

Why do you want to use a single sqlite3_stmt* from multiple threads
at the same time?

Dan.



> Could someone please clarify this (and maybe add some documentation)?
>
> Cheers,
>
> Shawn Wilsher
> Mozilla Developer
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to