sl@0: # 2008 April 14 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # The focus of this file is in making sure that rolling back sl@0: # a statement journal works correctly. sl@0: # sl@0: # $Id: tempdb.test,v 1.1 2008/04/15 00:02:00 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # Use a temporary database. sl@0: # sl@0: db close sl@0: sqlite3 db {} sl@0: sl@0: # Force a statement journal rollback on a database file that sl@0: # has never been opened. sl@0: # sl@0: do_test tempdb-1.1 { sl@0: execsql { sl@0: BEGIN; sl@0: CREATE TABLE t1(x UNIQUE); sl@0: CREATE TABLE t2(y); sl@0: INSERT INTO t2 VALUES('hello'); sl@0: INSERT INTO t2 VALUES(NULL); sl@0: } sl@0: # Because of the transaction, the temporary database file sl@0: # has not even been opened yet. The following statement sl@0: # will cause a statement journal rollback on this non-existant sl@0: # file. sl@0: catchsql { sl@0: INSERT INTO t1 sl@0: SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END sl@0: FROM t2; sl@0: } sl@0: } {1 oops} sl@0: sl@0: # Verify that no writes occurred in t1. sl@0: # sl@0: do_test tempdb-1.2 { sl@0: execsql { sl@0: SELECT * FROM t1 sl@0: } sl@0: } {} sl@0: sl@0: finish_test