1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/journal1.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,67 @@
1.4 +# 2005 March 15
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests to make sure that leftover journals from
1.17 +# prior databases do not try to rollback into new databases.
1.18 +#
1.19 +# $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $
1.20 +
1.21 +
1.22 +set testdir [file dirname $argv0]
1.23 +source $testdir/tester.tcl
1.24 +
1.25 +# These tests will not work on windows because windows uses
1.26 +# manditory file locking which breaks the file copy command.
1.27 +#
1.28 +if {$tcl_platform(platform)=="windows"} {
1.29 + finish_test
1.30 + return
1.31 +}
1.32 +
1.33 +# Create a smaple database
1.34 +#
1.35 +do_test journal1-1.1 {
1.36 + execsql {
1.37 + CREATE TABLE t1(a,b);
1.38 + INSERT INTO t1 VALUES(1,randstr(10,400));
1.39 + INSERT INTO t1 VALUES(2,randstr(10,400));
1.40 + INSERT INTO t1 SELECT a+2, a||b FROM t1;
1.41 + INSERT INTO t1 SELECT a+4, a||b FROM t1;
1.42 + SELECT count(*) FROM t1;
1.43 + }
1.44 +} 8
1.45 +
1.46 +# Make changes to the database and save the journal file.
1.47 +# Then delete the database. Replace the the journal file
1.48 +# and try to create a new database with the same name. The
1.49 +# old journal should not attempt to rollback into the new
1.50 +# database.
1.51 +#
1.52 +do_test journal1-1.2 {
1.53 + execsql {
1.54 + BEGIN;
1.55 + DELETE FROM t1;
1.56 + }
1.57 + file copy -force test.db-journal test.db-journal-bu
1.58 + execsql {
1.59 + ROLLBACK;
1.60 + }
1.61 + db close
1.62 + file delete test.db
1.63 + file copy test.db-journal-bu test.db-journal
1.64 + sqlite3 db test.db
1.65 + catchsql {
1.66 + SELECT * FROM sqlite_master
1.67 + }
1.68 +} {0 {}}
1.69 +
1.70 +finish_test