1d24c5b1cSdan# 2011 May 09 2d24c5b1cSdan# 3d24c5b1cSdan# The author disclaims copyright to this source code. In place of 4d24c5b1cSdan# a legal notice, here is a blessing: 5d24c5b1cSdan# 6d24c5b1cSdan# May you do good and not evil. 7d24c5b1cSdan# May you find forgiveness for yourself and forgive others. 8d24c5b1cSdan# May you share freely, never taking more than you give. 9d24c5b1cSdan# 10d24c5b1cSdan#*********************************************************************** 11d24c5b1cSdan# 12d24c5b1cSdan# This file contains tests for using WAL databases in read-only mode. 13d24c5b1cSdan# 14d24c5b1cSdan 15d24c5b1cSdanset testdir [file dirname $argv0] 16d24c5b1cSdansource $testdir/tester.tcl 17d24c5b1cSdansource $testdir/malloc_common.tcl 18d24c5b1cSdanset ::testprefix walro2 19d24c5b1cSdan 20d24c5b1cSdan# And only if the build is WAL-capable. 21d24c5b1cSdan# 22d24c5b1cSdanifcapable !wal { 23d24c5b1cSdan finish_test 24d24c5b1cSdan return 25d24c5b1cSdan} 26d24c5b1cSdan 27d24c5b1cSdandb close 28d24c5b1cSdansqlite3_shutdown 29d24c5b1cSdansqlite3_config_uri 1 30d24c5b1cSdansqlite3 db test.db 31d24c5b1cSdan 32d24c5b1cSdando_execsql_test 1.0 { 33d24c5b1cSdan CREATE TABLE t1(b); 34d24c5b1cSdan PRAGMA journal_mode = wal; 35d24c5b1cSdan INSERT INTO t1 VALUES('hello'); 36d24c5b1cSdan INSERT INTO t1 VALUES('world'); 37d24c5b1cSdan INSERT INTO t1 VALUES('!'); 38d24c5b1cSdan INSERT INTO t1 VALUES('world'); 39d24c5b1cSdan INSERT INTO t1 VALUES('hello'); 40d24c5b1cSdan PRAGMA cache_size = 10; 41d24c5b1cSdan BEGIN; 42d24c5b1cSdan WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<30 ) 43d24c5b1cSdan INSERT INTO t1(b) SELECT randomblob(800) FROM s; 44d24c5b1cSdan} {wal} 45*bcb416a9Smistachkinfile_control_persist_wal db 1; db close 46d24c5b1cSdanfaultsim_save_and_close 47d24c5b1cSdan 48d24c5b1cSdando_faultsim_test 1 -faults oom* -prep { 49d24c5b1cSdan catch { db close } 50d24c5b1cSdan faultsim_restore 51d24c5b1cSdan sqlite3 db file:test.db?readonly_shm=1 52d24c5b1cSdan} -body { 53d24c5b1cSdan execsql { SELECT * FROM t1 } 54d24c5b1cSdan} -test { 55d24c5b1cSdan faultsim_test_result {0 {hello world ! world hello}} 56d24c5b1cSdan} 57d24c5b1cSdan 58d24c5b1cSdan 59d24c5b1cSdan 60d24c5b1cSdanfinish_test 61