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 # This file implements regression tests for SQLite library.
12 # The focus of this file is in making sure that rolling back
13 # a statement journal works correctly.
15 # $Id: tempdb.test,v 1.4 2009/06/05 17:09:12 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 if {[atomic_batch_write test.db]} {
25 # Use a temporary database.
30 # Force a statement journal rollback on a database file that
31 # has never been opened.
36 CREATE TABLE t1(x UNIQUE);
38 INSERT INTO t2 VALUES('hello');
39 INSERT INTO t2 VALUES(NULL);
41 # Because of the transaction, the temporary database file
42 # has not even been opened yet. The following statement
43 # will cause a statement journal rollback on this non-existant
47 SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END
52 # Verify that no writes occurred in t1.
61 # Set $::jrnl_in_memory if the journal file is expected to be in-memory.
62 # Similarly, set $::subj_in_memory if the sub-journal file is expected
63 # to be in memory. These variables are used to calculate the expected
64 # number of open files in the test cases below.
66 set jrnl_in_memory [expr {[permutation] eq "inmemory_journal"}]
67 set subj_in_memory [expr {$jrnl_in_memory || $TEMP_STORE>=2}]
74 CREATE TABLE t1 (a PRIMARY KEY, b, c);
75 CREATE TABLE t2 (a, b, c);
77 INSERT INTO t1 VALUES(1, 2, 3);
78 INSERT INTO t1 VALUES(4, 5, 6);
79 INSERT INTO t2 VALUES(7, 8, 9);
80 INSERT INTO t2 SELECT * FROM t1;
82 catchsql { INSERT INTO t1 SELECT * FROM t2 }
83 set sqlite_open_file_count
84 } [expr 1 + (0==$jrnl_in_memory)]
87 PRAGMA temp_store = 'memory';
90 INSERT INTO t1 VALUES(1, 2, 3);
91 INSERT INTO t1 VALUES(4, 5, 6);
92 INSERT INTO t2 SELECT * FROM t1;
94 catchsql { INSERT INTO t1 SELECT * FROM t2 }
95 set sqlite_open_file_count
96 } [expr 1 + (0==$jrnl_in_memory)]