blob: c89dd2b4c9e073951c2c6af796e17f11e49a5097 [file] [log] [blame]
drh165ffe92005-03-15 17:09:30 +00001# 2005 March 15
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#
13# This file implements tests to make sure that leftover journals from
14# prior databases do not try to rollback into new databases.
15#
drh8aa60cb2005-03-20 22:54:56 +000016# $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $
drh165ffe92005-03-15 17:09:30 +000017
18
19set testdir [file dirname $argv0]
20source $testdir/tester.tcl
21
drh8aa60cb2005-03-20 22:54:56 +000022# These tests will not work on windows because windows uses
mistachkinfda06be2011-08-02 00:57:34 +000023# manditory file locking which breaks the copy_file command.
drh8aa60cb2005-03-20 22:54:56 +000024#
25if {$tcl_platform(platform)=="windows"} {
26 finish_test
27 return
28}
29
drh165ffe92005-03-15 17:09:30 +000030# Create a smaple database
31#
32do_test journal1-1.1 {
33 execsql {
34 CREATE TABLE t1(a,b);
35 INSERT INTO t1 VALUES(1,randstr(10,400));
36 INSERT INTO t1 VALUES(2,randstr(10,400));
37 INSERT INTO t1 SELECT a+2, a||b FROM t1;
38 INSERT INTO t1 SELECT a+4, a||b FROM t1;
39 SELECT count(*) FROM t1;
40 }
41} 8
42
43# Make changes to the database and save the journal file.
mistachkind5578432012-08-25 10:01:29 +000044# Then delete the database. Replace the journal file
drh165ffe92005-03-15 17:09:30 +000045# and try to create a new database with the same name. The
46# old journal should not attempt to rollback into the new
47# database.
48#
49do_test journal1-1.2 {
50 execsql {
51 BEGIN;
52 DELETE FROM t1;
53 }
mistachkinfda06be2011-08-02 00:57:34 +000054 forcecopy test.db-journal test.db-journal-bu
drh165ffe92005-03-15 17:09:30 +000055 execsql {
56 ROLLBACK;
57 }
58 db close
mistachkinfda06be2011-08-02 00:57:34 +000059 delete_file test.db
60 copy_file test.db-journal-bu test.db-journal
drh165ffe92005-03-15 17:09:30 +000061 sqlite3 db test.db
62 catchsql {
63 SELECT * FROM sqlite_master
64 }
65} {0 {}}
66
67finish_test