On 22 Jun 2013, at 1:28pm, Lukas Haase <lukasha...@gmx.at> wrote:

> I use sqlite3_open_v2 with flag SQLITE_OPEN_READONLY to open an SQLite
> database. When different processes access the same file (read-only) in
> Win, can I be sure that there won't be any problems?

Bees may eat your hat.  Your local bar may cancel Mimosa Mondays.  What kinds 
of problem are you asking us about ?

> Furthermore, I open another database with SQLITE_OPEN_READWRITE |
> SQLITE_OPEN_CREATE. When different processes access the same database in
> in Win, are write operations synchronized automatically or do I need to
> care about synchronization myself?

SQLite handles synchronization itself unless you tell it not to (probably using 
PRAGMAs). If you just do your _open_v2() and issue SQLite commands then you can 
rely on SQLite handling all necessary locking for you.  You should, of course, 
still be checking the result codes returned by your sqlite3 API calls.

> Background: My Win32 app uses SQLite3 to store data/settings. Since the
> beginning, I just restricted the app to one instance to avoid any
> problems with parallel access to the files. Now I want to remove this
> constraint and aks myself if I need to do anything else except removing
> the single-instance check.

Don’t forget that even if a process opens a file for READONLY it can still be 
blocked because /another/ process has the file locked while it is writing to 
it.  Using READONLY does not mean you no longer have to care about file locking 
in your application.  But the usual SQLite rules apply: set your timeout to 
whatever you consider appropriate:

<http://www.sqlite.org/pragma.html#pragma_busy_timeout>

and pay attention to any result codes which are not SQLITE_OK.  If you do those 
things most other things take care of themselves.

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

Reply via email to