Exclusive transactions and Select statements

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Exclusive transactions and Select statements

Carsten Müncheberg
Hi,

I am experimenting with EXCLUSIVE transactions today, and was confused
that after one connection began an EXCLUSIVE transaction, another one
could still execute a SELECT statement, because quoting from
https://www.sqlite.org/lang_transaction.html

"After a BEGIN EXCLUSIVE, no other database connection except for
read_uncommitted connections will be able to read the database and no
other connection without exception will be able to write the database
until the transaction is complete."

I do understand the concept of the different lock types and that a
SELECT statement does not implicitly start a transaction, but the quoted
paragraph does not make this clear in my mind, or am I reading it wrong?
Hearing your opinions on this is highly appreciated.

--
Carsten

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Exclusive transactions and Select statements

Simon Slavin-3
On 20 Dec 2018, at 11:19am, Carsten Müncheberg <[hidden email]> wrote:

> I am experimenting with EXCLUSIVE transactions today, and was confused that after one connection began an EXCLUSIVE transaction, another one could still execute a SELECT statement

Your database is probably in WAL mode:

<https://www.sqlite.org/wal.html>

This is the newer, arguably better, mode which allows the programmer to do exactly what you describe.  A database only locks up if more than one connection tries to write at the same time.

Find out which mode it's in using this PRAGMA:

<https://www.sqlite.org/pragma.html#pragma_journal_mode>

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users