On Monday, 4 March, 2019 20:23, Rowan Worth <row...@dug.com> wrote:

>On Sun, 3 Mar 2019 at 20:53, Keith Medcalf <kmedc...@dessus.com> wrote:

>> Statements which were in progress that were permitted to proceed
>> (ie, where the next step did not return an abort error) continue 
>> with a read lock in place (ie, as if they were part of an implicit 
>> transaction on the connection) and once all those statements are 
>> completed, the read locks are released.  You can BEGIN another 
>> transaction on the same connection (or another connection) 
>> and the locks will be escalated as you requested in the
>> same fashion as would normally be expected for an in-progress
>> implicit transaction.

> Wait what? If I've understood correctly you're describing a 
> situation where statements outlive their transaction context? 

>Something like:
>
>
>    sqlite3 *db; // initialised elsewhere
>
>    sqlite3_stmt *stmt;
>    int rc;
>
>    sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, NULL);
>    stmt = sqlite3_prepare_v2(db, "SELECT * FROM some_table", -1,
>&stmt, 0);
>    rc = sqlite3_step(stmt); // advance to first row
>    sqlite3_exec(db, "COMMIT", NULL, NULL, NULL);
>
>    rc = sqlite3_step(stmt); // advance to second row?
>    ...
>    sqlite3_finalize(stmt);
>
>And the sqlite3_step() following the transaction acquires a new read-
>lock?
>Or it prevents the COMMIT from dropping the read-lock?

>It seems bizarre that this is even possible, so I may have
>misunderstood!

It appears that changes are committed (assuming that the COMMIT was successful) 
however the read lock is not released (that is, after the commit the changes 
are visible to other connections).  However, there is no longer a transaction 
in progress on the original connection (the one the commit was issued against) 
and it is in autocommit mode and still holding a read lock (and is still 
repeatable read with respect to changes committed on another connection).  

I believe this is consistent with the documentation and operates appropriately 
(that is, as would be expected) for the journaling mode (delete or wal).

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.





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

Reply via email to