Richard Klein <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm upgrading from sqlite 2 to 3, and am trying to get a handle > on the new lock states. > > Here is my current understanding (by "process" I mean a process > *or* thread that has opened the database):
Or two separate database connections (obtained by separate calls to sqlite3_open_v2()), unless you have shared cache enabled using sqlite3_enable_shared_cache(). > > ---------------------------------------------------------------- > > A database is in the UNLOCKED state if every process holds *no* > lock of any kind on the database. > > A database is in the SHARED state if every process holds either > no lock or a SHARED lock. Processes holding a SHARED lock may > read, but not write, the database. > > A database is in the RESERVED state if one of the processes has > a RESERVED lock. Only *one* process at a time can hold a RESERVED > lock. The process holding the RESERVED lock intends to write to > the database file by the time its current transaction ends. Every > other process must hold either no lock or a SHARED lock. A process > holding no lock can acquire a SHARED lock, but nothing stronger > than that. Processes holding SHARED locks can continue to read. > > A database is in the PENDING state if one of the processes has > a PENDING lock. Only *one* process at a time can hold a PENDING > lock. The process holding the PENDING lock intends to write to > the database file as soon as all other processes drop their SHARED > locks. Every other process must hold either no lock or a SHARED > lock. A process holding no lock cannot acquire a lock of any kind. > Processes holding SHARED locks can continue to read. > > A database is in the EXCLUSIVE state if one of the processes has > an EXCLUSIVE lock. Only *one* process at a time can hold an EX- > CLUSIVE lock. The process holding the EXCLUSIVE lock is currently > writing to the database file. Every other process must hold *no* > lock. No other process can acquire a lock of any kind. > > ---------------------------------------------------------------- > > Do I have this right? > Correct. On the other hand, our hope as always been that you do not need to understand any of this in order to use SQLite. It should all just work. The only time you might to know this stuff is when you are trying to squeeze every last ounce of concurrency out of the system. -- D. Richard Hipp <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------