xref: /sqlite-3.40.0/test/memjournal2.test (revision cf2ad7ae)
1# 2022 Jan 01
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11# Tests focused on the in-memory journal.
12#
13# TESTRUNNER: slow
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17source $testdir/malloc_common.tcl
18set testprefix memjournal2
19
20do_execsql_test 1.0 {
21  PRAGMA journal_mode = memory;
22  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
23} {memory}
24
25set nRow [expr 2000]
26
27do_execsql_test 1.1 {
28  BEGIN;
29    WITH s(i) AS (
30      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<$nRow
31    )
32    INSERT INTO t1 SELECT NULL, randomblob(700) FROM s;
33}
34
35for {set jj 200} {$jj <= 300} {incr jj} {
36  do_execsql_test 1.2.$jj.1 {
37    SAVEPOINT one;
38      UPDATE t1 SET b=randomblob(700) WHERE a<=$jj;
39  }
40  do_execsql_test 1.2.$jj.2 {
41      SAVEPOINT two;
42        UPDATE t1 SET b=randomblob(700) WHERE a==1;
43      ROLLBACK TO two;
44      RELEASE two;
45  }
46  do_execsql_test 1.2.$jj.3 {
47      SAVEPOINT two;
48        UPDATE t1 SET b=randomblob(700) WHERE a==1;
49      ROLLBACK TO two;
50      RELEASE two;
51  }
52
53  do_execsql_test 1.2.$jj.4 {
54    PRAGMA integrity_check;
55    ROLLBACK TO one;
56    RELEASE one;
57  } {ok}
58}
59
60
61finish_test
62
63
64