mirror of
https://github.com/sqlite/sqlite.git
synced 2025-12-24 14:17:58 +03:00
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:
18
manifest
18
manifest
@@ -1,5 +1,5 @@
|
||||
C Add\smutexes\sto\sfix\sa\srace\scondition\sin\swal.c.\sThis\sisn't\sa\svery\sgood\sfix.
|
||||
D 2010-04-26T10:40:52
|
||||
C Add\sthe\s"wal"\spermutation\sto\srun\sexisting\stest\sfiles\ssavepoint.test\sand\ssavepoint2.test\sin\sWAL\smode.
|
||||
D 2010-04-26T12:39:04
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@@ -532,7 +532,7 @@ F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
|
||||
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
|
||||
F test/pcache.test eebc4420b37cb07733ae9b6e99c9da7c40dd6d58
|
||||
F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16
|
||||
F test/permutations.test 6117bae41935a787cc92faee81e91f813580eccb
|
||||
F test/permutations.test e9a9070862e3c675f0844815054cfd2ed4ed9c66
|
||||
F test/pragma.test 6960f9efbce476f70ba9ee2171daf5042f9e3d8a
|
||||
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
|
||||
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
|
||||
@@ -548,8 +548,8 @@ F test/rollback.test 73355ad4492ff9a3a31e61c7e5eb5e01a1de94ca
|
||||
F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b
|
||||
F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287
|
||||
F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9
|
||||
F test/savepoint.test f2ede4b643ad87ead36c041c72d774a1f5c8a564
|
||||
F test/savepoint2.test 427c8b20f43d3edf17a290c6788ae9e2703ac51c
|
||||
F test/savepoint.test 500ef5afb383107fd3b7d055cdeb015d36d1bc76
|
||||
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
|
||||
F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
|
||||
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
|
||||
F test/savepoint5.test 0735db177e0ebbaedc39812c8d065075d563c4fd
|
||||
@@ -603,7 +603,7 @@ F test/tclsqlite.test 7378a4e7474d9ffdb7c930086112b829e5955fb0
|
||||
F test/tempdb.test 1bf52da28a9c24e29717362a87722dff08feb72b
|
||||
F test/temptable.test f42121a0d29a62f00f93274464164177ab1cc24a
|
||||
F test/temptrigger.test b0273db072ce5f37cf19140ceb1f0d524bbe9f05
|
||||
F test/tester.tcl 49d76f12940160d623da104f995530fc6ee8f46f
|
||||
F test/tester.tcl 17082172a11795f9bc3e843aadb463ff76050c68
|
||||
F test/thread001.test a3e6a7254d1cb057836cb3145b60c10bf5b7e60f
|
||||
F test/thread002.test afd20095e6e845b405df4f2c920cb93301ca69db
|
||||
F test/thread003.test b824d4f52b870ae39fc5bae4d8070eca73085dca
|
||||
@@ -808,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 56fe5d7624f840417152bcc63efbe21a5f557920
|
||||
R 262915592f11e9609982ee307c6e8694
|
||||
P 3d159939cc2beb18c4ca0c8e9a99a75d4107e6e4
|
||||
R 9cdc568754b75f48338d755d9a93a206
|
||||
U dan
|
||||
Z 883881034efc398d53801b8849d7e631
|
||||
Z e32fb56774989323e02682dddebb9008
|
||||
|
||||
@@ -1 +1 @@
|
||||
3d159939cc2beb18c4ca0c8e9a99a75d4107e6e4
|
||||
205e5d8ac08f7d7853427b4cd235fca125155d2d
|
||||
@@ -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
|
||||
#############################################################################
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE
|
||||
# and ROLLBACK TO comands are correctly parsed, and that the auto-commit
|
||||
# flag is correctly set and unset as a result.
|
||||
#
|
||||
do_test savepoint-1.1 {
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
SAVEPOINT sp1;
|
||||
RELEASE sp1;
|
||||
@@ -93,6 +93,7 @@ do_test savepoint-1.5 {
|
||||
do_test savepoint-1.6 {
|
||||
execsql COMMIT
|
||||
} {}
|
||||
wal_check_journal_mode savepoint-1.7
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# These tests - savepoint-2.* - test rollbacks and releases of savepoints
|
||||
@@ -175,36 +176,42 @@ do_test savepoint-2.11 {
|
||||
}
|
||||
execsql { SELECT * FROM t1 }
|
||||
} {}
|
||||
wal_check_journal_mode savepoint-2.12
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# This block of tests - savepoint-3.* - test that when a transaction
|
||||
# savepoint is rolled back, locks are not released from database files.
|
||||
# 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 {
|
||||
execsql { SAVEPOINT "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main unlocked temp closed}
|
||||
|
||||
do_test savepoint-3.2 {
|
||||
execsql { INSERT INTO t1 VALUES(1, 2, 3) }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.3 {
|
||||
execsql { ROLLBACK TO "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.4 {
|
||||
execsql { INSERT INTO t1 VALUES(1, 2, 3) }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.5 {
|
||||
execsql { RELEASE "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main unlocked temp closed}
|
||||
if {[wal_is_wal_mode]==0} {
|
||||
do_test savepoint-3.1 {
|
||||
execsql { SAVEPOINT "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main unlocked temp closed}
|
||||
|
||||
do_test savepoint-3.2 {
|
||||
execsql { INSERT INTO t1 VALUES(1, 2, 3) }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.3 {
|
||||
execsql { ROLLBACK TO "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.4 {
|
||||
execsql { INSERT INTO t1 VALUES(1, 2, 3) }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main reserved temp closed}
|
||||
|
||||
do_test savepoint-3.5 {
|
||||
execsql { RELEASE "transaction" }
|
||||
execsql { PRAGMA lock_status }
|
||||
} {main unlocked temp closed}
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Test that savepoints that include schema modifications are handled
|
||||
@@ -264,6 +271,7 @@ do_test savepoint-4.7 {
|
||||
do_test savepoint-4.8 {
|
||||
execsql COMMIT
|
||||
} {}
|
||||
wal_check_journal_mode savepoint-4.9
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
# Test some logic errors to do with the savepoint feature.
|
||||
@@ -312,6 +320,18 @@ ifcapable incrblob {
|
||||
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 {
|
||||
execsql {
|
||||
SAVEPOINT main;
|
||||
@@ -320,17 +340,28 @@ ifcapable incrblob {
|
||||
} {}
|
||||
do_test savepoint-5.4.2 {
|
||||
sqlite3 db2 test.db
|
||||
execsql { BEGIN ; SELECT * FROM blobs } db2
|
||||
catchsql { RELEASE main }
|
||||
} {1 {database is locked}}
|
||||
do_test savepoint-5.4.3 {
|
||||
db2 close
|
||||
catchsql { RELEASE main }
|
||||
} {0 {}}
|
||||
do_test savepoint-5.4.4 {
|
||||
execsql { BEGIN ; SELECT count(*) FROM blobs } db2
|
||||
} {1}
|
||||
if {[wal_is_wal_mode]} {
|
||||
do_test savepoint-5.4.3 { catchsql "RELEASE main" } {0 {}}
|
||||
do_test savepoint-5.4.4 { db2 close } {}
|
||||
} else {
|
||||
do_test savepoint-5.4.3 {
|
||||
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 }
|
||||
} {{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
|
||||
@@ -342,8 +373,9 @@ ifcapable {autovacuum && pragma} {
|
||||
sqlite3 db test.db
|
||||
|
||||
do_test savepoint-6.1 {
|
||||
execsql {
|
||||
PRAGMA auto_vacuum = incremental;
|
||||
execsql { PRAGMA auto_vacuum = incremental }
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
CREATE INDEX i1 ON t1(a, b);
|
||||
BEGIN;
|
||||
@@ -376,6 +408,8 @@ ifcapable {autovacuum && pragma} {
|
||||
} {}
|
||||
|
||||
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
|
||||
|
||||
do_test savepoint-7.1 {
|
||||
execsql { PRAGMA auto_vacuum = incremental }
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
PRAGMA auto_vacuum = incremental;
|
||||
PRAGMA cache_size = 10;
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
@@ -449,13 +484,15 @@ do_test savepoint-7.3.2 {
|
||||
}
|
||||
execsql { PRAGMA integrity_check }
|
||||
} {ok}
|
||||
wal_check_journal_mode savepoint-7.3.3
|
||||
|
||||
do_test savepoint-7.4.1 {
|
||||
db close
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
execsql { PRAGMA auto_vacuum = incremental }
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
PRAGMA auto_vacuum = incremental;
|
||||
CREATE TABLE t1(a, b, PRIMARY KEY(a, b));
|
||||
INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));
|
||||
BEGIN;
|
||||
@@ -497,6 +534,7 @@ do_test savepoint-7.5.2 {
|
||||
DROP TABLE t5;
|
||||
}
|
||||
} {}
|
||||
wal_check_journal_mode savepoint-7.5.3
|
||||
|
||||
# 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]
|
||||
|
||||
|
||||
do_test savepoint-10.2.1 {
|
||||
file delete -force test3.db
|
||||
file delete -force test2.db
|
||||
execsql {
|
||||
ATTACH 'test2.db' AS aux1;
|
||||
ATTACH 'test3.db' AS aux2;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE main.t1(x, y);
|
||||
CREATE TABLE aux1.t2(x, y);
|
||||
CREATE TABLE aux2.t3(x, y);
|
||||
SELECT name FROM sqlite_master
|
||||
UNION ALL
|
||||
SELECT name FROM aux1.sqlite_master
|
||||
UNION ALL
|
||||
SELECT name FROM aux2.sqlite_master;
|
||||
}
|
||||
} {t1 t2 t3}
|
||||
do_test savepoint-10.2.2 {
|
||||
execsql { PRAGMA lock_status }
|
||||
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
|
||||
|
||||
do_test savepoint-10.2.3 {
|
||||
execsql {
|
||||
SAVEPOINT one;
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
PRAGMA lock_status;
|
||||
}
|
||||
} [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
|
||||
do_test savepoint-10.2.4 {
|
||||
execsql {
|
||||
INSERT INTO t3 VALUES(3, 4);
|
||||
PRAGMA lock_status;
|
||||
}
|
||||
} [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
|
||||
do_test savepoint-10.2.5 {
|
||||
execsql {
|
||||
SAVEPOINT two;
|
||||
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');
|
||||
if {[wal_is_wal_mode]==0} {
|
||||
do_test savepoint-10.2.1 {
|
||||
file delete -force test3.db
|
||||
file delete -force test2.db
|
||||
execsql {
|
||||
ATTACH 'test2.db' AS aux1;
|
||||
ATTACH 'test3.db' AS aux2;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE main.t1(x, y);
|
||||
CREATE TABLE aux1.t2(x, y);
|
||||
CREATE TABLE aux2.t3(x, y);
|
||||
SELECT name FROM sqlite_master
|
||||
UNION ALL
|
||||
SELECT name FROM aux1.sqlite_master
|
||||
UNION ALL
|
||||
SELECT name FROM aux2.sqlite_master;
|
||||
}
|
||||
} {t1 t2 t3}
|
||||
do_test savepoint-10.2.2 {
|
||||
execsql { PRAGMA lock_status }
|
||||
} [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]
|
||||
|
||||
do_test savepoint-10.2.3 {
|
||||
execsql {
|
||||
SAVEPOINT one;
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
PRAGMA lock_status;
|
||||
}
|
||||
} [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]
|
||||
do_test savepoint-10.2.4 {
|
||||
execsql {
|
||||
INSERT INTO t3 VALUES(3, 4);
|
||||
PRAGMA lock_status;
|
||||
}
|
||||
} [list main reserved temp $templockstate aux1 unlocked aux2 reserved]
|
||||
do_test savepoint-10.2.5 {
|
||||
execsql {
|
||||
SAVEPOINT two;
|
||||
INSERT INTO t2 VALUES('c', 'd');
|
||||
SAVEPOINT three;
|
||||
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]
|
||||
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;
|
||||
INSERT INTO t2 VALUES('c', 'd');
|
||||
SAVEPOINT three;
|
||||
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
|
||||
@@ -722,8 +762,9 @@ do_test savepoint-11.1 {
|
||||
db close
|
||||
file delete -force test.db
|
||||
sqlite3 db test.db
|
||||
execsql { PRAGMA auto_vacuum = full; }
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
PRAGMA auto_vacuum = full;
|
||||
CREATE TABLE t1(a, b, UNIQUE(a, b));
|
||||
INSERT INTO t1 VALUES(1, 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
|
||||
do_test savepoint-11.8 {
|
||||
execsql { ROLLBACK }
|
||||
execsql { PRAGMA checkpoint }
|
||||
file size test.db
|
||||
} {8192}
|
||||
|
||||
|
||||
do_test savepoint-11.9 {
|
||||
execsql {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
@@ -782,6 +823,7 @@ do_test savepoint-11.11 {
|
||||
do_test savepoint-11.12 {
|
||||
execsql {SELECT * FROM t2}
|
||||
} {1 2 3 4}
|
||||
wal_check_journal_mode savepoint-11.13
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests - savepoint-12.* - test the interaction of
|
||||
@@ -815,50 +857,53 @@ do_test savepoint-12.3 {
|
||||
do_test savepoint-12.4 {
|
||||
execsql { SAVEPOINT one }
|
||||
} {}
|
||||
wal_check_journal_mode savepoint-12.5
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests - savepoint-13.* - test the interaction of
|
||||
# savepoints and "journal_mode = off".
|
||||
#
|
||||
do_test savepoint-13.1 {
|
||||
db close
|
||||
catch {file delete -force test.db}
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
COMMIT;
|
||||
PRAGMA journal_mode = off;
|
||||
}
|
||||
} {off}
|
||||
do_test savepoint-13.2 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 SELECT a+4,b+4 FROM t1;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_test savepoint-13.3 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t1 VALUES(11, 12);
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_test savepoint-13.4 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(13, 14);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t1 VALUES(15, 16);
|
||||
ROLLBACK TO s1;
|
||||
ROLLBACK;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
|
||||
if {[wal_is_wal_mode]==0} {
|
||||
do_test savepoint-13.1 {
|
||||
db close
|
||||
catch {file delete -force test.db}
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
COMMIT;
|
||||
PRAGMA journal_mode = off;
|
||||
}
|
||||
} {off}
|
||||
do_test savepoint-13.2 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 SELECT a+4,b+4 FROM t1;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_test savepoint-13.3 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t1 VALUES(11, 12);
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_test savepoint-13.4 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(13, 14);
|
||||
SAVEPOINT s1;
|
||||
INSERT INTO t1 VALUES(15, 16);
|
||||
ROLLBACK TO s1;
|
||||
ROLLBACK;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
|
||||
# Tests in this file are quite similar to those run by trans.test and
|
||||
# avtrans.test.
|
||||
#
|
||||
@@ -23,6 +24,7 @@ proc signature {} {
|
||||
}
|
||||
|
||||
do_test savepoint2-1 {
|
||||
wal_set_journal_mode
|
||||
execsql {
|
||||
PRAGMA cache_size=10;
|
||||
BEGIN;
|
||||
@@ -42,6 +44,7 @@ do_test savepoint2-1 {
|
||||
SELECT count(*) FROM t3;
|
||||
}
|
||||
} {1024}
|
||||
wal_check_journal_mode savepoint2-1.1
|
||||
|
||||
unset -nocomplain ::sig
|
||||
unset -nocomplain SQL
|
||||
@@ -140,6 +143,9 @@ for {set ii 2} {$ii < ($iterations+2)} {incr ii} {
|
||||
sqlite3_get_autocommit db
|
||||
} {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
|
||||
|
||||
@@ -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
|
||||
# to non-zero, then set the global variable $AUTOVACUUM to 1.
|
||||
|
||||
Reference in New Issue
Block a user