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 #***********************************************************************
12 # The tests in this file check that SQLite uses (or does not use) a
13 # statement journal for various SQL statements.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 if {[atomic_batch_write test.db]} {
25 execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) }
28 # The following tests verify the method used for the tests in this file -
29 # that if a statement journal is required by a statement it is opened and
30 # remains open until the current transaction is committed or rolled back.
32 # This only work if SQLITE_TEMP_STORE!=3
34 if {$::TEMP_STORE==3} {
39 set sqlite_open_file_count
43 PRAGMA temp_store = file;
45 INSERT INTO t1 VALUES(1, 1);
47 set sqlite_open_file_count
51 INSERT INTO t1 SELECT a+1, b+1 FROM t1;
53 set sqlite_open_file_count
54 # 2016-03-04: statement-journal open deferred
58 set sqlite_open_file_count
63 INSERT INTO t1 SELECT a+2, b+2 FROM t1;
65 set sqlite_open_file_count
68 execsql { INSERT INTO t1 SELECT a+4, b+4 FROM t1 }
69 set sqlite_open_file_count
70 # 2016-03-04: statement-journal open deferred
74 set sqlite_open_file_count
78 proc filecount {testname sql expected} {
79 uplevel [list do_test $testname [subst -nocommand {
82 set ret [set sqlite_open_file_count]
88 filecount stmt-2.1 { INSERT INTO t1 VALUES(9, 9) } 2
89 filecount stmt-2.2 { REPLACE INTO t1 VALUES(9, 9) } 2
90 filecount stmt-2.3 { INSERT INTO t1 SELECT 9, 9 } 2
92 INSERT INTO t1 SELECT 9, 9;
93 INSERT INTO t1 SELECT 10, 10;
97 execsql { CREATE INDEX i1 ON t1(b) }
100 REPLACE INTO t1 VALUES(5, 5);
101 REPLACE INTO t1 VALUES(5, 5);