1# 2008 April 14 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# 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. 14# 15# $Id: tempdb.test,v 1.1 2008/04/15 00:02:00 drh Exp $ 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19 20# Use a temporary database. 21# 22db close 23sqlite3 db {} 24 25# Force a statement journal rollback on a database file that 26# has never been opened. 27# 28do_test tempdb-1.1 { 29 execsql { 30 BEGIN; 31 CREATE TABLE t1(x UNIQUE); 32 CREATE TABLE t2(y); 33 INSERT INTO t2 VALUES('hello'); 34 INSERT INTO t2 VALUES(NULL); 35 } 36 # Because of the transaction, the temporary database file 37 # has not even been opened yet. The following statement 38 # will cause a statement journal rollback on this non-existant 39 # file. 40 catchsql { 41 INSERT INTO t1 42 SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END 43 FROM t2; 44 } 45} {1 oops} 46 47# Verify that no writes occurred in t1. 48# 49do_test tempdb-1.2 { 50 execsql { 51 SELECT * FROM t1 52 } 53} {} 54 55finish_test 56