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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/lock_common.tcl
16 source $testdir/malloc_common.tcl
24 set sql { PRAGMA journal_mode = memory }
28 PRAGMA journal_mode = memory;
29 PRAGMA locking_mode = exclusive;
33 tv devchar safe_append
38 set sql { PRAGMA journal_mode = WAL }
41 set sql { PRAGMA auto_vacuum = 1 }
44 set sql { PRAGMA synchronous = off }
53 do_test pager2-1.$otn.0 {
54 faultsim_delete_and_reopen
57 PRAGMA cache_size = 10;
58 CREATE TABLE t1(i INTEGER PRIMARY KEY, j blob);
67 70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
68 43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
69 2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
71 86 34 26 50 41 85 58 44 89 22 6 51 45 46 58 32 97 6 1 12 32 2
72 69 39 48 71 33 31 5 58 90 43 24 54 12 9 18 57 4 38 91 42 27 45
73 50 38 56 29 10 0 26 37 83 1 78 15 47 30 75 62 46 29 68 5 30 4
74 27 96 33 95 79 75 56 10 29 70 32 75 52 88 5 36 50 57 46 63 88 65
76 44 95 64 20 24 35 69 61 61 2 35 92 42 46 23 98 78 1 38 72 79 35
77 94 37 13 59 5 93 27 58 80 75 58 7 67 13 10 76 84 4 8 70 81 45
78 8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
79 29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
83 set now [db one {SELECT count(i) FROM t1}]
85 execsql { COMMIT ; BEGIN }
87 do_test pager2.1.$otn.$tn {
90 SELECT COALESCE(max(i), 0) FROM t1;
91 PRAGMA integrity_check;
97 if { $x>=$lowpoint } {
98 execsql "ROLLBACK TO sp_$x"
100 execsql "DELETE FROM t1 WHERE i>$x"
103 } elseif {$now < $x} {
104 for {set k $now} {$k < $x} {incr k} {
105 execsql "SAVEPOINT sp_$k"
106 execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
109 do_execsql_test pager2.1.$otn.$tn {
110 SELECT COALESCE(max(i), 0) FROM t1;
111 PRAGMA integrity_check;
120 #-------------------------------------------------------------------------
121 # pager2-2.1: Test a ROLLBACK with journal_mode=off.
122 # pager2-2.2: Test shrinking the database (auto-vacuum) with
126 faultsim_delete_and_reopen
128 CREATE TABLE t1(a, b);
129 PRAGMA journal_mode = off;
131 INSERT INTO t1 VALUES(1, 2);
137 faultsim_delete_and_reopen
139 PRAGMA auto_vacuum = incremental;
140 PRAGMA page_size = 1024;
141 PRAGMA journal_mode = off;
142 CREATE TABLE t1(a, b);
143 INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
145 PRAGMA incremental_vacuum;
150 ifcapable shared_cache {
151 #-------------------------------------------------------------------------
152 # Test that shared in-memory databases seem to work.
160 sqlite3 db1 {file:test.db?mode=memory&cache=shared}
161 sqlite3 db2 {file:test.db?mode=memory&cache=shared}
164 db1 eval { CREATE TABLE t1(a, b) }
165 db2 eval { INSERT INTO t1 VALUES(1, 2) }
166 list [catch { db3 eval { INSERT INTO t1 VALUES(3, 4) } } msg] $msg
167 } {1 {no such table: t1}}