Am 19.11.2008 um 17:53 schrieb Paul Clarke:

> My current understanding, which may well be imperfect, is as follows:
>
>
>
> 1)     If you open an Sqlite database more than once (i.e. issue
> multiple calls to sqlite3_open) for reading and writing then you will
> get locking conflicts between the different connections
>
>
>
> 2)     So in order to avoid these problems, I have opened one  
> connection
> to the database but now I need to use it on multiple threads
> concurrently
>
>
>
> 3)     If I do this then calls to sqlite3_prepare return with
> SQLITE_MISUSE
>
>
>
> 4)     The Sqlite implementation of the iPhone says it is version  
> 3.4 so
> it should support multiple threading but I don't know if it is  
> compiled
> with the THREADSAFE preprocessor macro - does anyone know?
>
>
>
> 5)     The FAQ suggests this should be possible but other posts  
> suggest
> that you cannot share a connection between different threads
>
>
>
> I need to have background threads that are updating the database  
> whilst
> the foreground thread is also accessing the database - is this  
> possible
> on the iPhone and if so, how?
>
>
>
> (I realise that I could pipeline all database requests through a  
> single
> thread, probably the foreground one, but that will not fit with our
> application architecture)

You can call sqlite3_threadsafe() to find out whether the version on  
the iPhone is compiled with THREADSAFE on (assuming this API existed  
in 3.4).

Assuming it's compiled as THREADSAFE, if you want to use the database  
in multiple threads, you'll have to open one connection per thread - I  
believe the ability to pass connections between threads was introduced  
after 3.4...

Alternatively, you could always statically link your own version of  
sqlite into your application. While you certainly don't want to be  
excessive with code size on the iPhone, sqlite probably only adds a  
few 100k of code size, and you'll be certain that it's exactly your  
tailored setup...

</jum>


_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to