I observed the following behavior when using the wal_checkpoint PRAGMA
in TRUNCATE mode:
SQLite version 3.22.0 2018-01-22 18:45:57
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open test.db
sqlite> PRAGMA journal_mode = WAL;
sqlite> create table test ( key INTEGER PRIMARY KEY, val INTEGER );
sqlite> insert into test values ( 5, 6 );
sqlite> insert into test values ( 6, 6 );
sqlite> PRAGMA wal_checkpoint(TRUNCATE);
According to the documentation, the second and third values should
correspond to the number of pages in the write-ahead log and the number
of pages that have been moved back to the database file.  This works as
expected in the other modes, but in TRUNCATE mode the second and third
return values are always zero.
I believe this is because walCheckpoint() triggers a call to
walRestartHdr() if the mode is SQLITE_CHEKPOINT_TRUNCATE.  Once
walCheckpoint() returns, sqlite3WalCheckpoint() attempts to extract the
values from the already restarted wal header.

Has anyone else expirenced this issue?

Joshua Watt
sqlite-users mailing list

Reply via email to