3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing the operation of the library in
13 # "PRAGMA journal_mode=WAL" mode.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 source $testdir/malloc_common.tcl
19 source $testdir/lock_common.tcl
21 ifcapable !wal {finish_test ; return }
22 set testprefix walfault2
24 #-------------------------------------------------------------------------
25 # Inject faults while truncating the wal file.
28 PRAGMA auto_vacuum = 0;
29 CREATE TABLE t1(a, b);
30 PRAGMA journal_mode = wal;
32 SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
34 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
36 faultsim_save_and_close
38 do_faultsim_test 1 -prep {
41 sqlite3 db file:test.db?psow=0 -uri 1
42 file_control_powersafe_overwrite db 0
44 PRAGMA wal_checkpoint;
45 PRAGMA journal_size_limit = 10000;
46 PRAGMA synchronous = full;
49 execsql { INSERT INTO t1 VALUES(1,1) }
51 faultsim_test_result {0 {}}
54 #-------------------------------------------------------------------------
55 # Inject faults while rewriting checksums.
59 PRAGMA auto_vacuum = 0;
60 CREATE TABLE t1(a, b);
61 PRAGMA journal_mode = wal;
63 SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 30
65 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
67 faultsim_save_and_close
69 do_faultsim_test 2 -prep {
70 faultsim_restore_and_reopen
72 PRAGMA cache_size = 2;
74 UPDATE t1 SET a=randomblob(400);
75 UPDATE t1 SET b=randomblob(400);
76 UPDATE t1 SET a=randomblob(400);
77 UPDATE t1 SET b=randomblob(400);
78 UPDATE t1 SET a=randomblob(400);
79 UPDATE t1 SET b=randomblob(400);
80 UPDATE t1 SET a=randomblob(400);
81 UPDATE t1 SET b=randomblob(400);
86 faultsim_test_result {0 {}}