SQLite persistence: Wrap rewrite in transaction

This commit is contained in:
Lars Mueller 2022-03-01 12:03:56 +01:00
parent 5bce5c79cc
commit b7ae328aab

@ -230,11 +230,13 @@ CREATE TABLE IF NOT EXISTS table_entries (
end end
function ptab:rewrite() function ptab:rewrite()
exec(self, "BEGIN EXCLUSIVE TRANSACTION")
exec(self, "DELETE FROM table_entries") exec(self, "DELETE FROM table_entries")
self.highest_table_id = 0 self.highest_table_id = 0
self.table_ids = {} self.table_ids = {}
self.counts = {} self.counts = {}
add_table(self, self.root) add_table(self, self.root)
exec(self, "COMMIT TRANSACTION")
end end
function ptab:set(table, key, value) function ptab:set(table, key, value)