I'd like to essentially commit changes to disk in the middle of the 
transaction, resulting in a transaction that is atomic with respect to other 
database connections but is two atomic transactions with respect to the 
filesystem.

When I first found the locking_mode pragma, my understanding was that it 
disabled the releasing of locks on transaction commit or rollback. So I came up 
with this:

pragma locking_mode=exclusive;
begin;
-- transaction part 1
commit;
pragma locking_mode=normal; -- exclusive lock will be released when next 
transaction completes
begin;
-- transaction part 2
commit;

The problem is that this doesn't work in WAL mode. My understanding according 
to pragma lock_status is that readers in WAL mode never release their shared 
locks, so acquiring an exclusive lock like this would require all readers to be 
closed. It seems like any connection in WAL mode acquires a shared lock, and 
there's some other lock being used to synchronize writers that pragma 
lock_status isn't showing me. So in order to do this I'd need some way to 
control that other write synchronization lock.

Is there a sane way to do this?

~Theodore

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

Reply via email to