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