On Fri, Apr 20, 2012 at 12:00 PM, George <pinkisntw...@gmail.com> wrote:

> On 4/20/12, Richard Hipp <d...@sqlite.org> wrote:
> > On Fri, Apr 20, 2012 at 10:38 AM, George <pinkisntw...@gmail.com> wrote:
> >
> >> The webpage [1] mentions that if the sqlite library is linked twice
> >> into the same application there is the possibility that the database
> >> will be corrupted.
> >>
> >> Is this also possible when two different processes (each of which has
> >> only linked the library once) are accessing the same database? If not,
> >> how does the latter case differ from the former?
> >>
> >
> > SQLite is normally proof against corruption when two or more processes
> are
> > writing to the same database file - unless of course you do something
> else
> > wrong as described in How To Corrupt An SQLite
> > Database.<http://www.sqlite.org/howtocorrupt.html>
> >
> >
> > The issue with two different versions of the library linked into the same
> > process space causing problems has to do with the fact that when multiple
> > threads are using SQLite, SQLite must use global variables to coordinate
> > access among those threads.  But if there are two different versions of
> the
> > library in the process, there are then two different sets of global
> > variables.  One thread might be using one set of global variables and
> > another thread might be using another set.  And so the threads do not
> know
> > about each other and do not properly coordinate their activities.
> >
>
> But how is the two-thread issue different to the two-process one?
>

Two processes use file locking to coordinate access.  But posix advisory
locks do not work for two threads within the same process, so when it is
two threads running, global variables have to be used.



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



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

Reply via email to