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 #***********************************************************************
12 # This file contains tests for using WAL with persistent WAL file mode.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 source $testdir/lock_common.tcl
18 set ::testprefix walpersist
25 do_test walpersist-1.0 {
27 PRAGMA journal_mode=WAL;
29 INSERT INTO t1 VALUES(randomblob(5000));
31 file exists test.db-wal
33 do_test walpersist-1.1 {
34 file exists test.db-shm
36 do_test walpersist-1.2 {
38 list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
40 do_test walpersist-1.3 {
42 db eval {SELECT length(a) FROM t1}
44 do_test walpersist-1.4 {
45 list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
47 do_test walpersist-1.5 {
48 file_control_persist_wal db -1
50 do_test walpersist-1.6 {
51 file_control_persist_wal db 1
53 do_test walpersist-1.7 {
54 file_control_persist_wal db -1
56 do_test walpersist-1.8 {
57 file_control_persist_wal db 0
59 do_test walpersist-1.9 {
60 file_control_persist_wal db -1
62 do_test walpersist-1.10 {
63 file_control_persist_wal db 1
65 do_test walpersist-1.11 {
67 list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]
70 # Make sure the journal_size_limit works to limit the size of the
71 # persisted wal file. In persistent-wal mode, any non-negative
72 # journal_size_limit causes the WAL file to be truncated to zero bytes
75 forcedelete test.db test.db-shm test.db-wal
76 do_test walpersist-2.1 {
79 PRAGMA journal_mode=WAL;
80 PRAGMA wal_autocheckpoint=OFF;
81 PRAGMA journal_size_limit=12000;
83 INSERT INTO t1 VALUES(randomblob(50000));
84 UPDATE t1 SET x=randomblob(50000);
86 expr {[file size test.db-wal]>100000}
88 do_test walpersist-2.2 {
89 file_control_persist_wal db 1
91 concat [file exists test.db-wal] [file size test.db-wal]
93 do_test walpersist-2.3 {
95 execsql { PRAGMA integrity_check }
100 forcedelete test.db test.db-shm test.db-wal
103 PRAGMA page_size = 1024;
104 PRAGMA journal_mode = WAL;
105 PRAGMA wal_autocheckpoint=128;
106 PRAGMA journal_size_limit=16384;
107 CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
111 for {set i 0} {$i<200} {incr i} {
112 execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) }
114 file_control_persist_wal db 1
117 do_test walpersist-3.3 {
118 file size test.db-wal
120 do_test walpersist-3.4 {
122 execsql { PRAGMA integrity_check }