Add the "wal" permutation to run existing test files savepoint.test and savepoint2.test in WAL mode.

FossilOrigin-Name: 205e5d8ac08f7d7853427b4cd235fca125155d2d
This commit is contained in:
dan
2010-04-26 12:39:03 +00:00
parent cd11fb28c3
commit 71cb518fca
6 changed files with 296 additions and 202 deletions
+9 -9
View File
@@ -1,5 +1,5 @@
C Add\smutexes\sto\sfix\sa\srace\scondition\sin\swal.c.\sThis\sisn't\sa\svery\sgood\sfix. C Add\sthe\s"wal"\spermutation\sto\srun\sexisting\stest\sfiles\ssavepoint.test\sand\ssavepoint2.test\sin\sWAL\smode.
D 2010-04-26T10:40:52 D 2010-04-26T12:39:04
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -532,7 +532,7 @@ F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
F test/pcache.test eebc4420b37cb07733ae9b6e99c9da7c40dd6d58 F test/pcache.test eebc4420b37cb07733ae9b6e99c9da7c40dd6d58
F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16 F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16
F test/permutations.test 6117bae41935a787cc92faee81e91f813580eccb F test/permutations.test e9a9070862e3c675f0844815054cfd2ed4ed9c66
F test/pragma.test 6960f9efbce476f70ba9ee2171daf5042f9e3d8a F test/pragma.test 6960f9efbce476f70ba9ee2171daf5042f9e3d8a
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
@@ -548,8 +548,8 @@ F test/rollback.test 73355ad4492ff9a3a31e61c7e5eb5e01a1de94ca
F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b
F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287
F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9 F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9
F test/savepoint.test f2ede4b643ad87ead36c041c72d774a1f5c8a564 F test/savepoint.test 500ef5afb383107fd3b7d055cdeb015d36d1bc76
F test/savepoint2.test 427c8b20f43d3edf17a290c6788ae9e2703ac51c F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0 F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd
@@ -603,7 +603,7 @@ F test/tclsqlite.test 7378a4e7474d9ffdb7c930086112b829e5955fb0
F test/tempdb.test 1bf52da28a9c24e29717362a87722dff08feb72b F test/tempdb.test 1bf52da28a9c24e29717362a87722dff08feb72b
F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a
F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05 F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05
F test/tester.tcl 49d76f12940160d623da104f995530fc6ee8f46f F test/tester.tcl 17082172a11795f9bc3e843aadb463ff76050c68
F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f
F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db
F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca
@@ -808,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 56fe5d7624f840417152bcc63efbe21a5f557920 P 3d159939cc2beb18c4ca0c8e9a99a75d4107e6e4
R 262915592f11e9609982ee307c6e8694 R 9cdc568754b75f48338d755d9a93a206
U dan U dan
Z 883881034efc398d53801b8849d7e631 Z e32fb56774989323e02682dddebb9008
+1 -1
View File
@@ -1 +1 @@
3d159939cc2beb18c4ca0c8e9a99a75d4107e6e4 205e5d8ac08f7d7853427b4cd235fca125155d2d
+7
View File
@@ -756,6 +756,13 @@ if {[info commands register_demovfs] != ""} {
} }
} }
run_tests "wal" -description {
Run tests with journal_mode=WAL
} -include {
savepoint.test
savepoint2.test
}
# End of tests # End of tests
############################################################################# #############################################################################
+237 -192
View File
@@ -14,13 +14,13 @@
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE # The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE
# and ROLLBACK TO comands are correctly parsed, and that the auto-commit # and ROLLBACK TO comands are correctly parsed, and that the auto-commit
# flag is correctly set and unset as a result. # flag is correctly set and unset as a result.
# #
do_test savepoint-1.1 { do_test savepoint-1.1 {
wal_set_journal_mode
execsql { execsql {
SAVEPOINT sp1; SAVEPOINT sp1;
RELEASE sp1; RELEASE sp1;
@@ -93,6 +93,7 @@ do_test savepoint-1.5 {
do_test savepoint-1.6 { do_test savepoint-1.6 {
execsql COMMIT execsql COMMIT
} {} } {}
wal_check_journal_mode savepoint-1.7
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# These tests - savepoint-2.* - test rollbacks and releases of savepoints # These tests - savepoint-2.* - test rollbacks and releases of savepoints
@@ -175,36 +176,42 @@ do_test savepoint-2.11 {
} }
execsql { SELECT * FROM t1 } execsql { SELECT * FROM t1 }
} {} } {}
wal_check_journal_mode savepoint-2.12
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# This block of tests - savepoint-3.* - test that when a transaction # This block of tests - savepoint-3.* - test that when a transaction
# savepoint is rolled back, locks are not released from database files. # savepoint is rolled back, locks are not released from database files.
# And that when a transaction savepoint is released, they are released. # And that when a transaction savepoint is released, they are released.
#
# These tests do not work in WAL mode. WAL mode does not take RESERVED
# locks on the database file.
# #
do_test savepoint-3.1 { if {[wal_is_wal_mode]==0} {
execsql { SAVEPOINT "transaction" } do_test savepoint-3.1 {
execsql { PRAGMA lock_status } execsql { SAVEPOINT "transaction" }
} {main unlocked temp closed} execsql { PRAGMA lock_status }
} {main unlocked temp closed}
do_test savepoint-3.2 {
execsql { INSERT INTO t1 VALUES(1, 2, 3) } do_test savepoint-3.2 {
execsql { PRAGMA lock_status } execsql { INSERT INTO t1 VALUES(1, 2, 3) }
} {main reserved temp closed} execsql { PRAGMA lock_status }
} {main reserved temp closed}
do_test savepoint-3.3 {
execsql { ROLLBACK TO "transaction" } do_test savepoint-3.3 {
execsql { PRAGMA lock_status } execsql { ROLLBACK TO "transaction" }
} {main reserved temp closed} execsql { PRAGMA lock_status }
} {main reserved temp closed}
do_test savepoint-3.4 {
execsql { INSERT INTO t1 VALUES(1, 2, 3) } do_test savepoint-3.4 {
execsql { PRAGMA lock_status } execsql { INSERT INTO t1 VALUES(1, 2, 3) }
} {main reserved temp closed} execsql { PRAGMA lock_status }
} {main reserved temp closed}
do_test savepoint-3.5 {
execsql { RELEASE "transaction" } do_test savepoint-3.5 {
execsql { PRAGMA lock_status } execsql { RELEASE "transaction" }
} {main unlocked temp closed} execsql { PRAGMA lock_status }
} {main unlocked temp closed}
}
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# Test that savepoints that include schema modifications are handled # Test that savepoints that include schema modifications are handled
@@ -264,6 +271,7 @@ do_test savepoint-4.7 {
do_test savepoint-4.8 { do_test savepoint-4.8 {
execsql COMMIT execsql COMMIT
} {} } {}
wal_check_journal_mode savepoint-4.9
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# Test some logic errors to do with the savepoint feature. # Test some logic errors to do with the savepoint feature.
@@ -312,6 +320,18 @@ ifcapable incrblob {
execsql {release abc} execsql {release abc}
} {} } {}
# Rollback mode:
#
# Open a savepoint transaction and insert a row into the database. Then,
# using a second database handle, open a read-only transaction on the
# database file. Check that the savepoint transaction cannot be committed
# until after the read-only transaction has been closed.
#
# WAL mode:
#
# As above, except that the savepoint transaction can be successfully
# committed before the read-only transaction has been closed.
#
do_test savepoint-5.4.1 { do_test savepoint-5.4.1 {
execsql { execsql {
SAVEPOINT main; SAVEPOINT main;
@@ -320,17 +340,28 @@ ifcapable incrblob {
} {} } {}
do_test savepoint-5.4.2 { do_test savepoint-5.4.2 {
sqlite3 db2 test.db sqlite3 db2 test.db
execsql { BEGIN ; SELECT * FROM blobs } db2 execsql { BEGIN ; SELECT count(*) FROM blobs } db2
catchsql { RELEASE main } } {1}
} {1 {database is locked}} if {[wal_is_wal_mode]} {
do_test savepoint-5.4.3 { do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
db2 close do_test savepoint-5.4.4 { db2 close } {}
catchsql { RELEASE main } } else {
} {0 {}} do_test savepoint-5.4.3 {
do_test savepoint-5.4.4 { catchsql { RELEASE main }
} {1 {database is locked}}
do_test savepoint-5.4.4 {
db2 close
catchsql { RELEASE main }
} {0 {}}
}
do_test savepoint-5.4.5 {
execsql { SELECT x FROM blobs WHERE rowid = 2 } execsql { SELECT x FROM blobs WHERE rowid = 2 }
} {{another blob}} } {{another blob}}
do_test savepoint-5.4.6 {
execsql { SELECT count(*) FROM blobs }
} {2}
} }
wal_check_journal_mode savepoint-5.5
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# The following tests, savepoint-6.*, test an incr-vacuum inside of a # The following tests, savepoint-6.*, test an incr-vacuum inside of a
@@ -342,8 +373,9 @@ ifcapable {autovacuum && pragma} {
sqlite3 db test.db sqlite3 db test.db
do_test savepoint-6.1 { do_test savepoint-6.1 {
execsql { execsql { PRAGMA auto_vacuum = incremental }
PRAGMA auto_vacuum = incremental; wal_set_journal_mode
execsql {
CREATE TABLE t1(a, b, c); CREATE TABLE t1(a, b, c);
CREATE INDEX i1 ON t1(a, b); CREATE INDEX i1 ON t1(a, b);
BEGIN; BEGIN;
@@ -376,6 +408,8 @@ ifcapable {autovacuum && pragma} {
} {} } {}
integrity_check savepoint-6.4 integrity_check savepoint-6.4
wal_check_journal_mode savepoint-6.5
} }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@@ -387,8 +421,9 @@ file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
do_test savepoint-7.1 { do_test savepoint-7.1 {
execsql { PRAGMA auto_vacuum = incremental }
wal_set_journal_mode
execsql { execsql {
PRAGMA auto_vacuum = incremental;
PRAGMA cache_size = 10; PRAGMA cache_size = 10;
BEGIN; BEGIN;
CREATE TABLE t1(a PRIMARY KEY, b); CREATE TABLE t1(a PRIMARY KEY, b);
@@ -449,13 +484,15 @@ do_test savepoint-7.3.2 {
} }
execsql { PRAGMA integrity_check } execsql { PRAGMA integrity_check }
} {ok} } {ok}
wal_check_journal_mode savepoint-7.3.3
do_test savepoint-7.4.1 { do_test savepoint-7.4.1 {
db close db close
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
execsql { PRAGMA auto_vacuum = incremental }
wal_set_journal_mode
execsql { execsql {
PRAGMA auto_vacuum = incremental;
CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000)); INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
BEGIN; BEGIN;
@@ -497,6 +534,7 @@ do_test savepoint-7.5.2 {
DROP TABLE t5; DROP TABLE t5;
} }
} {} } {}
wal_check_journal_mode savepoint-7.5.3
# Test oddly named and quoted savepoints. # Test oddly named and quoted savepoints.
# #
@@ -598,120 +636,122 @@ do_test savepoint-10.1.3 {
set templockstate [lindex [db eval {PRAGMA lock_status}] 3] set templockstate [lindex [db eval {PRAGMA lock_status}] 3]
do_test savepoint-10.2.1 { if {[wal_is_wal_mode]==0} {
file delete -force test3.db do_test savepoint-10.2.1 {
file delete -force test2.db file delete -force test3.db
execsql { file delete -force test2.db
ATTACH 'test2.db' AS aux1; execsql {
ATTACH 'test3.db' AS aux2; ATTACH 'test2.db' AS aux1;
DROP TABLE t1; ATTACH 'test3.db' AS aux2;
CREATE TABLE main.t1(x, y); DROP TABLE t1;
CREATE TABLE aux1.t2(x, y); CREATE TABLE main.t1(x, y);
CREATE TABLE aux2.t3(x, y); CREATE TABLE aux1.t2(x, y);
SELECT name FROM sqlite_master CREATE TABLE aux2.t3(x, y);
UNION ALL SELECT name FROM sqlite_master
SELECT name FROM aux1.sqlite_master UNION ALL
UNION ALL SELECT name FROM aux1.sqlite_master
SELECT name FROM aux2.sqlite_master; UNION ALL
} SELECT name FROM aux2.sqlite_master;
} {t1 t2 t3} }
do_test savepoint-10.2.2 { } {t1 t2 t3}
execsql { PRAGMA lock_status } do_test savepoint-10.2.2 {
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked] execsql { PRAGMA lock_status }
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
do_test savepoint-10.2.3 {
execsql { do_test savepoint-10.2.3 {
SAVEPOINT one; execsql {
INSERT INTO t1 VALUES(1, 2); SAVEPOINT one;
PRAGMA lock_status; INSERT INTO t1 VALUES(1, 2);
} PRAGMA lock_status;
} [list main reserved temp $templockstate aux1 unlocked aux2 unlocked] }
do_test savepoint-10.2.4 { } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
execsql { do_test savepoint-10.2.4 {
INSERT INTO t3 VALUES(3, 4); execsql {
PRAGMA lock_status; INSERT INTO t3 VALUES(3, 4);
} PRAGMA lock_status;
} [list main reserved temp $templockstate aux1 unlocked aux2 reserved] }
do_test savepoint-10.2.5 { } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
execsql { do_test savepoint-10.2.5 {
SAVEPOINT two; execsql {
INSERT INTO t2 VALUES(5, 6);
PRAGMA lock_status;
}
} [list main reserved temp $templockstate aux1 reserved aux2 reserved]
do_test savepoint-10.2.6 {
execsql { SELECT * FROM t2 }
} {5 6}
do_test savepoint-10.2.7 {
execsql { ROLLBACK TO two }
execsql { SELECT * FROM t2 }
} {}
do_test savepoint-10.2.8 {
execsql { PRAGMA lock_status }
} [list main reserved temp $templockstate aux1 reserved aux2 reserved]
do_test savepoint-10.2.9 {
execsql { SELECT 'a', * FROM t1 UNION ALL SELECT 'b', * FROM t3 }
} {a 1 2 b 3 4}
do_test savepoint-10.2.9 {
execsql {
INSERT INTO t2 VALUES(5, 6);
RELEASE one;
}
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 2 5 6 3 4}
do_test savepoint-10.2.9 {
execsql { PRAGMA lock_status }
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
do_test savepoint-10.2.10 {
execsql {
SAVEPOINT one;
INSERT INTO t1 VALUES('a', 'b');
SAVEPOINT two; SAVEPOINT two;
INSERT INTO t2 VALUES('c', 'd'); INSERT INTO t2 VALUES(5, 6);
SAVEPOINT three; PRAGMA lock_status;
INSERT INTO t3 VALUES('e', 'f'); }
} } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
execsql { do_test savepoint-10.2.6 {
SELECT * FROM t1; execsql { SELECT * FROM t2 }
SELECT * FROM t2; } {5 6}
SELECT * FROM t3; do_test savepoint-10.2.7 {
} execsql { ROLLBACK TO two }
} {1 2 a b 5 6 c d 3 4 e f} execsql { SELECT * FROM t2 }
do_test savepoint-10.2.11 { } {}
execsql { ROLLBACK TO two } do_test savepoint-10.2.8 {
execsql { execsql { PRAGMA lock_status }
SELECT * FROM t1; } [list main reserved temp $templockstate aux1 reserved aux2 reserved]
SELECT * FROM t2; do_test savepoint-10.2.9 {
SELECT * FROM t3; execsql { SELECT 'a', * FROM t1 UNION ALL SELECT 'b', * FROM t3 }
} } {a 1 2 b 3 4}
} {1 2 a b 5 6 3 4} do_test savepoint-10.2.9 {
do_test savepoint-10.2.12 { execsql {
execsql { INSERT INTO t2 VALUES(5, 6);
INSERT INTO t3 VALUES('g', 'h'); RELEASE one;
ROLLBACK TO two; }
} execsql {
execsql { SELECT * FROM t1;
SELECT * FROM t1; SELECT * FROM t2;
SELECT * FROM t2; SELECT * FROM t3;
SELECT * FROM t3; }
} } {1 2 5 6 3 4}
} {1 2 a b 5 6 3 4} do_test savepoint-10.2.9 {
do_test savepoint-10.2.13 { execsql { PRAGMA lock_status }
execsql { ROLLBACK } } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
execsql {
SELECT * FROM t1; do_test savepoint-10.2.10 {
SELECT * FROM t2; execsql {
SELECT * FROM t3; SAVEPOINT one;
} INSERT INTO t1 VALUES('a', 'b');
} {1 2 5 6 3 4} SAVEPOINT two;
do_test savepoint-10.2.14 { INSERT INTO t2 VALUES('c', 'd');
execsql { PRAGMA lock_status } SAVEPOINT three;
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked] INSERT INTO t3 VALUES('e', 'f');
}
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 2 a b 5 6 c d 3 4 e f}
do_test savepoint-10.2.11 {
execsql { ROLLBACK TO two }
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 2 a b 5 6 3 4}
do_test savepoint-10.2.12 {
execsql {
INSERT INTO t3 VALUES('g', 'h');
ROLLBACK TO two;
}
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 2 a b 5 6 3 4}
do_test savepoint-10.2.13 {
execsql { ROLLBACK }
execsql {
SELECT * FROM t1;
SELECT * FROM t2;
SELECT * FROM t3;
}
} {1 2 5 6 3 4}
do_test savepoint-10.2.14 {
execsql { PRAGMA lock_status }
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
}
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# The following tests - savepoint-11.* - test the interaction of # The following tests - savepoint-11.* - test the interaction of
@@ -722,8 +762,9 @@ do_test savepoint-11.1 {
db close db close
file delete -force test.db file delete -force test.db
sqlite3 db test.db sqlite3 db test.db
execsql { PRAGMA auto_vacuum = full; }
wal_set_journal_mode
execsql { execsql {
PRAGMA auto_vacuum = full;
CREATE TABLE t1(a, b, UNIQUE(a, b)); CREATE TABLE t1(a, b, UNIQUE(a, b));
INSERT INTO t1 VALUES(1, randstr(1000,1000)); INSERT INTO t1 VALUES(1, randstr(1000,1000));
INSERT INTO t1 VALUES(2, randstr(1000,1000)); INSERT INTO t1 VALUES(2, randstr(1000,1000));
@@ -751,10 +792,10 @@ do_test savepoint-11.6 {
integrity_check savepoint-11.7 integrity_check savepoint-11.7
do_test savepoint-11.8 { do_test savepoint-11.8 {
execsql { ROLLBACK } execsql { ROLLBACK }
execsql { PRAGMA checkpoint }
file size test.db file size test.db
} {8192} } {8192}
do_test savepoint-11.9 { do_test savepoint-11.9 {
execsql { execsql {
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
@@ -782,6 +823,7 @@ do_test savepoint-11.11 {
do_test savepoint-11.12 { do_test savepoint-11.12 {
execsql {SELECT * FROM t2} execsql {SELECT * FROM t2}
} {1 2 3 4} } {1 2 3 4}
wal_check_journal_mode savepoint-11.13
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# The following tests - savepoint-12.* - test the interaction of # The following tests - savepoint-12.* - test the interaction of
@@ -815,50 +857,53 @@ do_test savepoint-12.3 {
do_test savepoint-12.4 { do_test savepoint-12.4 {
execsql { SAVEPOINT one } execsql { SAVEPOINT one }
} {} } {}
wal_check_journal_mode savepoint-12.5
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# The following tests - savepoint-13.* - test the interaction of # The following tests - savepoint-13.* - test the interaction of
# savepoints and "journal_mode = off". # savepoints and "journal_mode = off".
# #
do_test savepoint-13.1 { if {[wal_is_wal_mode]==0} {
db close do_test savepoint-13.1 {
catch {file delete -force test.db} db close
sqlite3 db test.db catch {file delete -force test.db}
execsql { sqlite3 db test.db
BEGIN; execsql {
CREATE TABLE t1(a PRIMARY KEY, b); BEGIN;
INSERT INTO t1 VALUES(1, 2); CREATE TABLE t1(a PRIMARY KEY, b);
COMMIT; INSERT INTO t1 VALUES(1, 2);
PRAGMA journal_mode = off; COMMIT;
} PRAGMA journal_mode = off;
} {off} }
do_test savepoint-13.2 { } {off}
execsql { do_test savepoint-13.2 {
BEGIN; execsql {
INSERT INTO t1 VALUES(3, 4); BEGIN;
INSERT INTO t1 SELECT a+4,b+4 FROM t1; INSERT INTO t1 VALUES(3, 4);
COMMIT; INSERT INTO t1 SELECT a+4,b+4 FROM t1;
} COMMIT;
} {} }
do_test savepoint-13.3 { } {}
execsql { do_test savepoint-13.3 {
BEGIN; execsql {
INSERT INTO t1 VALUES(9, 10); BEGIN;
SAVEPOINT s1; INSERT INTO t1 VALUES(9, 10);
INSERT INTO t1 VALUES(11, 12); SAVEPOINT s1;
COMMIT; INSERT INTO t1 VALUES(11, 12);
} COMMIT;
} {} }
do_test savepoint-13.4 { } {}
execsql { do_test savepoint-13.4 {
BEGIN; execsql {
INSERT INTO t1 VALUES(13, 14); BEGIN;
SAVEPOINT s1; INSERT INTO t1 VALUES(13, 14);
INSERT INTO t1 VALUES(15, 16); SAVEPOINT s1;
ROLLBACK TO s1; INSERT INTO t1 VALUES(15, 16);
ROLLBACK; ROLLBACK TO s1;
SELECT * FROM t1; ROLLBACK;
} SELECT * FROM t1;
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} }
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
}
finish_test finish_test
+6
View File
@@ -14,6 +14,7 @@
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# Tests in this file are quite similar to those run by trans.test and # Tests in this file are quite similar to those run by trans.test and
# avtrans.test. # avtrans.test.
# #
@@ -23,6 +24,7 @@ proc signature {} {
} }
do_test savepoint2-1 { do_test savepoint2-1 {
wal_set_journal_mode
execsql { execsql {
PRAGMA cache_size=10; PRAGMA cache_size=10;
BEGIN; BEGIN;
@@ -42,6 +44,7 @@ do_test savepoint2-1 {
SELECT count(*) FROM t3; SELECT count(*) FROM t3;
} }
} {1024} } {1024}
wal_check_journal_mode savepoint2-1.1
unset -nocomplain ::sig unset -nocomplain ::sig
unset -nocomplain SQL unset -nocomplain SQL
@@ -140,6 +143,9 @@ for {set ii 2} {$ii < ($iterations+2)} {incr ii} {
sqlite3_get_autocommit db sqlite3_get_autocommit db
} {1} } {1}
integrity_check savepoint2-$ii.6.1 integrity_check savepoint2-$ii.6.1
# Check that the connection is still running in WAL mode.
wal_check_journal_mode savepoint2-$ii.7
} }
unset -nocomplain ::sig unset -nocomplain ::sig
+36
View File
@@ -983,6 +983,42 @@ proc drop_all_tables {{db db}} {
} }
} }
#-------------------------------------------------------------------------
# If a test script is executed with global variable
# $::permutations_test_prefix set to "wal", then the tests are run
# in WAL mode. Otherwise, they should be run in rollback mode. The
# following Tcl procs are used to make this less intrusive:
#
# wal_set_journal_mode ?DB?
#
# If running a WAL test, execute "PRAGMA journal_mode = wal" using
# connection handle DB. Otherwise, this command is a no-op.
#
# wal_check_journal_mode TESTNAME ?DB?
#
# If running a WAL test, execute a tests case that fails if the main
# database for connection handle DB is not currently a WAL database.
# Otherwise (if not running a WAL permutation) this is a no-op.
#
# wal_is_wal_mode
#
# Returns true if this test should be run in WAL mode. False otherwise.
#
proc wal_is_wal_mode {} {
expr { [catch {set ::permutations_test_prefix} v]==0 && $v == "wal" }
}
proc wal_set_journal_mode {{db db}} {
if { [wal_is_wal_mode] } {
$db eval "PRAGMA journal_mode = WAL"
}
}
proc wal_check_journal_mode {testname {db db}} {
if { [wal_is_wal_mode] } {
$db eval { SELECT * FROM sqlite_master }
do_test $testname [list $db eval "PRAGMA main.journal_mode"] {wal}
}
}
# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set # If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1. # to non-zero, then set the global variable $AUTOVACUUM to 1.