SQLite Forum

You will note that `pragma locking_mode=exclusive` only works this way when the journal_mode is not wal.  Setting journal_mode=wal and locking_mode=exclusive have an entirely different meaning.

You might, for example, create a crc32 aggregate function.  Then you can set the user_version to the result of `select crc32(sql) from (select sql from sqlite_master order by sql))` which will verify that the database schema is exactly what you expect it to be.

The only reason for setting the journal_mode to wal after setting locking_mode normal is that after being in locking_mode exclusive in a non-wal journal_mode, the change does not "become apparent" until the next time the commit machinery runs (so you could `select count(*) from sqlite_master` or any other command in its place).