The docs do not mention that it does not apply in WAL mode:

https://sqlite.org/lang_transaction.html#immediate
- "After a BEGIN IMMEDIATE, no other database connection will be able to
write to the database"

I tested it out against the API with WAL mode enabled, it seems a "BEGIN
IMMEDIATE" will block other writers, so it cannot be used as a "read
transaction":

```
run(A, "PRAGMA journal_mode=WAL");
run(B, "PRAGMA journal_mode=WAL");


run(A, "CREATE TABLE t1(a PRIMARY KEY, b);");


run(B, "BEGIN IMMEDIATE");

run(A, "BEGIN");
run(A, "INSERT INTO t1 (a, b VALUES (1, 2), (3, 4)")); // SQLITE_BUSY
run(A, "INSERT INTO t1 (a, b VALUES (5, 6), (7, 8)"));
run(A, "COMMIT");

run(B, "SELECT * FROM t1");
```

I could of made a mistake though. Do you have an example/docs reference?

BEGIN READ is semantically what I was trying to describe as what I was
trying to achieve, I understand its not in the language!


On Tue, Jul 30, 2019 at 9:43 PM Simon Slavin <slav...@bigfraud.org> wrote:

> On 30 Jul 2019, at 9:39pm, test user <example.com.use...@gmail.com> wrote:
>
> > BEGIN IMMEDIATE will start a write transaction, which will block other
> writers with SQLITE_BUSY until its complete.
>
> This does not apply to WAL mode.  You wrote that you were using WAL mode.
>
> > What I would like is something like BEGIN READ
>
> The statement 'BEGIN READ' does not exist in SQlite.
>
> <https://www.sqlite.org/lang_transaction.html>
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to