Add test cases to restore coverage of pager.c and wal.c.
FossilOrigin-Name: 6cae552927392d8b735aa118c318d7468097ebeb
This commit is contained in:
parent
8c40800439
commit
e08c2066c9
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C If\sa\sdatabase\sfile\swith\sthe\sWAL\sflag\sset\sis\sopened\sin\sexclusive-locking\smode,\suse\sheap\smemory\sto\sstore\sthe\swal-index\sinstead\sof\sshared-memory.
|
||||
D 2010-11-01T17:38:25
|
||||
C Add\stest\scases\sto\srestore\scoverage\sof\spager.c\sand\swal.c.
|
||||
D 2010-11-01T18:45:09
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 2c8cefd962eca0147132c7cf9eaa4bb24c656f3f
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -566,7 +566,7 @@ F test/notify3.test d60923e186e0900f4812a845fcdfd8eea096e33a
|
||||
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
|
||||
F test/null.test a8b09b8ed87852742343b33441a9240022108993
|
||||
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
||||
F test/pager1.test fa74657dc832f0e21dc3ce60829feaee143296ba
|
||||
F test/pager1.test 07b06b89d50bc38bb118a18b99c7bee645b315de
|
||||
F test/pager2.test 0fbb6b6dc40ce1fecfe758c555a748ad2e9beaa3
|
||||
F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
|
||||
F test/pagerfault.test 3cd3537bf2efb4baef26c74878718f4a32926da4
|
||||
@ -829,10 +829,10 @@ F test/walbig.test e882bc1d014afffbfa2b6ba36e0f07d30a633ad0
|
||||
F test/walcksum.test a37b36375c595e61bdb7e1ec49b5f0979b6fc7ce
|
||||
F test/walcrash.test e763841551d6b23677ccb419797c1589dcbdbaf5
|
||||
F test/walcrash2.test 019d60b89d96c1937adb2b30b850ac7e86e5a142
|
||||
F test/walfault.test 1211c3c5f35142d93940c709c61fbaf58c3afab6
|
||||
F test/walfault.test 81ed760def1c1573151d416b0d09178cf006f9fd
|
||||
F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
|
||||
F test/walmode.test 22ddccd073c817ac9ead62b88ac446e8dedc7d2c
|
||||
F test/walnoshm.test 732391f72af2785d2758aaa8f9ae563d6d519b20
|
||||
F test/walnoshm.test a074428046408f4eb5c6a00e09df8cc97ff93317
|
||||
F test/walshared.test 6dda2293880c300baf5d791c307f653094585761
|
||||
F test/walslow.test d21625e2e99e11c032ce949e8a94661576548933
|
||||
F test/walthread.test a25a393c068a2b42b44333fa3fdaae9072f1617c
|
||||
@ -882,7 +882,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P db64843b540d23c58fe4de199a7fc40d44900bc4
|
||||
R 2b6e847446dd321925fabfa8d797522d
|
||||
P 8dd5c69198619866923c6053b71899c1fb8c4c67
|
||||
R 14f132430429bd624492110e4d1cae74
|
||||
U dan
|
||||
Z 4b3ff964892084a664463cd0c913ef99
|
||||
Z b450e3307830f974b5c903cf51078580
|
||||
|
@ -1 +1 @@
|
||||
8dd5c69198619866923c6053b71899c1fb8c4c67
|
||||
6cae552927392d8b735aa118c318d7468097ebeb
|
@ -2353,5 +2353,62 @@ do_test pager1-29.2 {
|
||||
file size test.db
|
||||
} [expr 4096*3]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that if an empty database file (size 0 bytes) is opened in
|
||||
# exclusive-locking mode, any journal file is deleted from the file-system
|
||||
# without being rolled back. And that the RESERVED lock obtained while
|
||||
# doing this is not released.
|
||||
#
|
||||
do_test pager1-30.1 {
|
||||
db close
|
||||
file delete test.db
|
||||
file delete test.db-journal
|
||||
set fd [open test.db-journal w]
|
||||
seek $fd [expr 512+1032*2]
|
||||
puts -nonewline $fd x
|
||||
close $fd
|
||||
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
PRAGMA locking_mode=EXCLUSIVE;
|
||||
SELECT count(*) FROM sqlite_master;
|
||||
PRAGMA lock_status;
|
||||
}
|
||||
} {exclusive 0 main reserved temp closed}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that if the "page-size" field in a journal-header is 0, the journal
|
||||
# file can still be rolled back. This is required for backward compatibility -
|
||||
# versions of SQLite prior to 3.5.8 always set this field to zero.
|
||||
#
|
||||
do_test pager1-31.1 {
|
||||
faultsim_delete_and_reopen
|
||||
execsql {
|
||||
PRAGMA cache_size = 10;
|
||||
PRAGMA page_size = 1024;
|
||||
CREATE TABLE t1(x, y, UNIQUE(x, y));
|
||||
INSERT INTO t1 VALUES(randomblob(1500), randomblob(1500));
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;
|
||||
BEGIN;
|
||||
UPDATE t1 SET y = randomblob(1499);
|
||||
}
|
||||
file copy test.db test.db2
|
||||
file copy test.db-journal test.db2-journal
|
||||
|
||||
hexio_write test.db2-journal 24 00000000
|
||||
sqlite3 db2 test.db2
|
||||
execsql { PRAGMA integrity_check } db2
|
||||
} {ok}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
@ -515,4 +515,33 @@ do_faultsim_test walfault-13.3 -prep {
|
||||
if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" }
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test fault-handling when wrapping around to the start of a WAL file.
|
||||
#
|
||||
do_test walfault-14-pre {
|
||||
faultsim_delete_and_reopen
|
||||
execsql {
|
||||
PRAGMA journal_mode = WAL;
|
||||
BEGIN;
|
||||
CREATE TABLE abc(a PRIMARY KEY);
|
||||
INSERT INTO abc VALUES(randomblob(1500));
|
||||
INSERT INTO abc VALUES(randomblob(1500));
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
do_faultsim_test walfault-14 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
db eval {
|
||||
PRAGMA wal_checkpoint;
|
||||
INSERT INTO abc VALUES(randomblob(1500));
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_integrity_check
|
||||
set nRow [db eval {SELECT count(*) FROM abc}]
|
||||
if {!(($nRow==2 && $testrc) || $nRow==3)} { error "Bad db content" }
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
@ -140,7 +140,45 @@ do_test 2.2.6 {
|
||||
} {a b c d e f g h}
|
||||
|
||||
db2 close
|
||||
db close
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# 3.1: Test that if locking_mode=EXCLUSIVE is set after the wal file is
|
||||
# opened, it is possible to drop back to locking_mode=NORMAL.
|
||||
#
|
||||
# 3.2: Test that if locking_mode=EXCLUSIVE is set before the wal file is
|
||||
# opened, it is not.
|
||||
#
|
||||
do_test 3.1 {
|
||||
sqlite3 db test.db -vfs tvfsshm
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
PRAGMA locking_mode = EXCLUSIVE;
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
PRAGMA locking_mode = NORMAL;
|
||||
INSERT INTO t1 VALUES(7, 8);
|
||||
}
|
||||
sqlite3 db2 test.db -vfs tvfsshm
|
||||
execsql { SELECT * FROM t1 } db2
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
db close
|
||||
db2 close
|
||||
do_test 3.2 {
|
||||
sqlite3 db test.db -vfs tvfsshm
|
||||
execsql {
|
||||
PRAGMA locking_mode = EXCLUSIVE;
|
||||
INSERT INTO t1 VALUES(9, 10);
|
||||
PRAGMA locking_mode = NORMAL;
|
||||
INSERT INTO t1 VALUES(11, 12);
|
||||
}
|
||||
sqlite3 db2 test.db -vfs tvfsshm
|
||||
catchsql { SELECT * FROM t1 } db2
|
||||
} {1 {database is locked}}
|
||||
db close
|
||||
db2 close
|
||||
|
||||
tvfs delete
|
||||
tvfsshm delete
|
||||
|
||||
finish_test
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user