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. Specifically,
12 # it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 set testprefix tkt-2d1a5c67d
22 ifcapable {!wal || !vtab} {finish_test; return}
24 for {set ii 1} {$ii<=10} {incr ii} {
25 do_test tkt-2d1a5c67d.1.$ii {
27 forcedelete test.db test.db-wal
29 db eval "PRAGMA cache_size=$::ii"
31 PRAGMA journal_mode=WAL;
33 CREATE INDEX t1b ON t1(b);
34 CREATE TABLE t2(x,y UNIQUE);
35 INSERT INTO t2 VALUES(3,4);
37 INSERT INTO t1(a,b) VALUES(1,2);
38 SELECT 'A', * FROM t2 WHERE y=4;
39 SELECT 'B', * FROM t1;
41 SELECT 'C', * FROM t1;
43 } {wal A 3 4 B 1 2 C 1 2}
47 forcedelete test.db test.db-wal
49 load_static_extension db wholenumber
51 PRAGMA journal_mode=WAL;
53 CREATE INDEX t1b ON t1(b);
55 CREATE VIRTUAL TABLE nums USING wholenumber;
56 INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
57 WHERE value BETWEEN 1 AND 1000;
60 for {set ii 1} {$ii<=10} {incr ii} {
61 do_test tkt-2d1a5c67d.2.$ii {
62 db eval "PRAGMA cache_size=$::ii"
66 INSERT INTO t1(a,b) VALUES(1,2);
67 SELECT sum(length(y)) FROM t2;
79 PRAGMA cache_size = 10;
80 CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
85 INSERT INTO t3 VALUES(NULL, randomblob(500));
86 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 2
87 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 4
88 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 8
89 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 16
90 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 32
91 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 64
92 INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 128
97 INSERT INTO t4 VALUES('xyz');
102 for {set i 1} {$i<100} {incr i} {
103 set b [db incrblob -readonly t3 b $i]
109 execsql { SELECT * FROM t4 WHERE a = 'xyz' }
113 foreach b $blobs { close $b }
114 execsql { SELECT * FROM t4 WHERE a = 'xyz' }
117 # Check that recovery works on the WAL file.
119 forcedelete test.db2-wal test.db2
121 copy_file test.db-wal test.db2-wal
122 copy_file test.db test.db2
124 execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2