On 29 Dec 2017, at 7:07pm, Ian Freeman <i...@ifreeman.net> wrote:

> Thanks, Simon. Indeed I did see that option. But I'm concerned about
> maintaining integrity in the middle of an power-interrupted commit,

This is not a problem for either WAL mode or the older journal modes.  If you 
avoid these commands

PRAGMA journal_mode = OFF
PRAGMA journal_mode = MEMORY
PRAGMA synchronous = OFF
PRAGMA synchronous = NORMAL

then SQLite will ensure that the database file always reflects your data as it 
was before the more recent COMMIT or after the most recent COMMIT.

SQLite has a lot of code in to ensure the best handling in the case of 
power-loss.  Each time a database file is reopened SQLite looks for tell-tales 
that it wasn’t properly closed, and uses a number of strategies to restore one 
of those two situations.  This includes comparing the state of the database 
file with the states of the associated files (-wal, -shm, etc.).

Because of this, do not delete/rename any of the associated files even when 
SQLite does not have them open.  SQLite must be able to find these files /in 
the same folder as the database file/.  If you ever back up one of those files, 
back them all up, including the database file, as a unit.  They are useless 
without copies of all the other files as they were at the same time.

Since the "synchronous" setting is default, the advice for installations where 
power-loss is not unexpected is to issue

PRAGMA synchronous = EXTRA

, to have the database in WAL mode if you want it (neither safer nor less safer 
with respect to power-loss), and leave everything else as it is.

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

Reply via email to