SQLite Forum

Database WAL snapshot
Thanks for your information. Your example should indeed work, but is not preferred since this currently is a read-only transaction.

Based on your description, however, I think my process should have worked. Maybe I didn't get it correctly?

 time  |  Program A           |  Program B   |  State of WAL file
  |    |  Open read-only      |              |  (empty)
  |    |  connection c1       |              |  c1
  v    |                      |              |
       |  start read          |              |  (empty)
       |  transaction on c1   |              |  c1
       |                      |              |
       |                      |  Modify the  |  |--commit1--|
       |                      |  database    |  c1
       |                      |              |
       |  Open read-only      |              |  |--commit1--|
       |  connection c2       |              |  c1          c2

       |                      |              |  |--commit1--|
       |                      |              |  c1
       |                      |              |  c2

Now, I'd like to move c2 to the same position as c1 ("no plates/plate 0"). The content/state/plate should still be there, since c1 has an open read transaction.

> `sqlite3_snapshot_open` sets the current read location to the "plate" number previously saved with `sqlite3_snapshot_get`. If that plate has been removed (put in the dishwasher) you can no longer go to that plate number because it is no longer in the queue, so you get an error.
> This is how it worked last time someone asked and I looked at it. Perhaps it has been updated to permit `sqlite3_snapshot_get` to work when the WAL is empty, but I don't know the answer to that. Based on what you are reporting, it would look like there must be a transaction in the WAL file.

The WAL file isn't empty, so from the documentation and your reply, I interpret that this should work. Maybe because the WAL was empty when I started connection/transaction c1?

If it doesn't and shouldn't work, is there another way to ensure c1 and c2 point at the same position? (Besides creating a "dummy commit")