Snapshot of upstream SQLite 3.37.2
[sqlcipher.git] / test / memjournal2.test
blob97d35a98d13937678b2a37567efd333560d47df6
1 # 2022 Jan 01
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 # Tests focused on the in-memory journal.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 source $testdir/malloc_common.tcl
17 set testprefix memjournal2
19 do_execsql_test 1.0 {
20   PRAGMA journal_mode = memory;
21   CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
22 } {memory}
24 set nRow [expr 2000]
26 do_execsql_test 1.1 {
27   BEGIN;
28     WITH s(i) AS (
29       SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$nRow
30     )
31     INSERT INTO t1 SELECT NULL, randomblob(700) FROM s;
34 for {set jj 200} {$jj <= 300} {incr jj} {
35   do_execsql_test 1.2.$jj.1 {
36     SAVEPOINT one; 
37       UPDATE t1 SET b=randomblob(700) WHERE a<=$jj;
38   }
39   do_execsql_test 1.2.$jj.2 {
40       SAVEPOINT two;
41         UPDATE t1 SET b=randomblob(700) WHERE a==1;
42       ROLLBACK TO two;
43       RELEASE two;
44   }
45   do_execsql_test 1.2.$jj.3 {
46       SAVEPOINT two;
47         UPDATE t1 SET b=randomblob(700) WHERE a==1;
48       ROLLBACK TO two;
49       RELEASE two;
50   }
52   do_execsql_test 1.2.$jj.4 {
53     PRAGMA integrity_check;
54     ROLLBACK TO one;
55     RELEASE one;
56   } {ok}
57
60 finish_test