xref: /sqlite-3.40.0/test/memjournal2.test (revision 554cb87d)
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
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16source $testdir/malloc_common.tcl
17set testprefix memjournal2
18
19do_execsql_test 1.0 {
20  PRAGMA journal_mode = memory;
21  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);
22} {memory}
23
24set nRow [expr 2000]
25
26do_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;
32}
33
34for {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  }
51
52  do_execsql_test 1.2.$jj.4 {
53    PRAGMA integrity_check;
54    ROLLBACK TO one;
55    RELEASE one;
56  } {ok}
57}
58
59
60finish_test
61
62
63