sl@0: # 2005 March 15 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: # sl@0: # This file implements tests to make sure that leftover journals from sl@0: # prior databases do not try to rollback into new databases. sl@0: # sl@0: # $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $ sl@0: sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # These tests will not work on windows because windows uses sl@0: # manditory file locking which breaks the file copy command. sl@0: # sl@0: if {$tcl_platform(platform)=="windows"} { sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: # Create a smaple database sl@0: # sl@0: do_test journal1-1.1 { sl@0: execsql { sl@0: CREATE TABLE t1(a,b); sl@0: INSERT INTO t1 VALUES(1,randstr(10,400)); sl@0: INSERT INTO t1 VALUES(2,randstr(10,400)); sl@0: INSERT INTO t1 SELECT a+2, a||b FROM t1; sl@0: INSERT INTO t1 SELECT a+4, a||b FROM t1; sl@0: SELECT count(*) FROM t1; sl@0: } sl@0: } 8 sl@0: sl@0: # Make changes to the database and save the journal file. sl@0: # Then delete the database. Replace the the journal file sl@0: # and try to create a new database with the same name. The sl@0: # old journal should not attempt to rollback into the new sl@0: # database. sl@0: # sl@0: do_test journal1-1.2 { sl@0: execsql { sl@0: BEGIN; sl@0: DELETE FROM t1; sl@0: } sl@0: file copy -force test.db-journal test.db-journal-bu sl@0: execsql { sl@0: ROLLBACK; sl@0: } sl@0: db close sl@0: file delete test.db sl@0: file copy test.db-journal-bu test.db-journal sl@0: sqlite3 db test.db sl@0: catchsql { sl@0: SELECT * FROM sqlite_master sl@0: } sl@0: } {0 {}} sl@0: sl@0: finish_test