mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add tests to pager1.test and pagerfault.test.
FossilOrigin-Name: 58c0b5bfed8c67cc3f2f4a6784d08c14e652c265
This commit is contained in:
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\stests\sto\spager1.test.
|
C Add\stests\sto\spager1.test\sand\spagerfault.test.
|
||||||
D 2010-06-18T18:59:49
|
D 2010-06-19T11:30:41
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
|
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -534,8 +534,8 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
|
|||||||
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
|
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
|
||||||
F test/null.test a8b09b8ed87852742343b33441a9240022108993
|
F test/null.test a8b09b8ed87852742343b33441a9240022108993
|
||||||
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
||||||
F test/pager1.test f2806eeba269efbe0132302b789f9fb4abf62264
|
F test/pager1.test d71580a4f358276520192f21fa2be4b8930bce86
|
||||||
F test/pagerfault.test 16e560bc4332d5b089b369d82ae4b65b8805b5eb
|
F test/pagerfault.test 424b0bbb3d458d36a94dfec89b05b0eab4d99ac8
|
||||||
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
|
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
|
||||||
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
|
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
|
||||||
F test/pcache.test eebc4420b37cb07733ae9b6e99c9da7c40dd6d58
|
F test/pcache.test eebc4420b37cb07733ae9b6e99c9da7c40dd6d58
|
||||||
@ -824,7 +824,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 ce0a4a9b5f981d066822a9ae63740c91b35bfc60
|
P 582fca89195af54e9668af249691654cfea63d04
|
||||||
R 43f6c397d741ef10ef5d1aeb6e2ade8c
|
R fbd44aafb92e6601ec3f8830a20d8a05
|
||||||
U dan
|
U dan
|
||||||
Z 6cf151c823519ced3c5ca7c23ec3a1bb
|
Z 2ad8778b11d258070a4981dade837d10
|
||||||
|
@ -1 +1 @@
|
|||||||
582fca89195af54e9668af249691654cfea63d04
|
58c0b5bfed8c67cc3f2f4a6784d08c14e652c265
|
@ -24,6 +24,8 @@ source $testdir/malloc_common.tcl
|
|||||||
#
|
#
|
||||||
# pager1-4.*: Hot-journal related tests.
|
# pager1-4.*: Hot-journal related tests.
|
||||||
#
|
#
|
||||||
|
# pager1-5.*: Cases related to multi-file commits.
|
||||||
|
#
|
||||||
|
|
||||||
proc do_execsql_test {testname sql result} {
|
proc do_execsql_test {testname sql result} {
|
||||||
uplevel do_test $testname [list "execsql {$sql}"] [list $result]
|
uplevel do_test $testname [list "execsql {$sql}"] [list $result]
|
||||||
@ -212,24 +214,33 @@ do_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}
|
|||||||
do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
|
do_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}
|
||||||
do_execsql_test pager1-3.6 { COMMIT } {}
|
do_execsql_test pager1-3.6 { COMMIT } {}
|
||||||
|
|
||||||
|
set otn 0
|
||||||
testvfs tv -default 1
|
testvfs tv -default 1
|
||||||
foreach code [list {
|
foreach code [list {
|
||||||
set s 512
|
set s 512
|
||||||
set sql { PRAGMA synchronous = off }
|
|
||||||
} {
|
} {
|
||||||
set s 1024
|
set s 1024
|
||||||
set sql { PRAGMA journal_mode = memory }
|
set sql { PRAGMA journal_mode = memory }
|
||||||
} {
|
} {
|
||||||
set s 2048
|
set s 2048
|
||||||
tv devchar safe_append
|
tv devchar safe_append
|
||||||
|
} {
|
||||||
|
set s 4096
|
||||||
} {
|
} {
|
||||||
set s 4096
|
set s 4096
|
||||||
set sql { PRAGMA journal_mode = WAL }
|
set sql { PRAGMA journal_mode = WAL }
|
||||||
|
} {
|
||||||
|
set s 8192
|
||||||
|
set sql { PRAGMA synchronous = off }
|
||||||
}] {
|
}] {
|
||||||
|
|
||||||
|
incr otn
|
||||||
|
set sql ""
|
||||||
|
tv devchar {}
|
||||||
eval $code
|
eval $code
|
||||||
tv sectorsize $s
|
tv sectorsize $s
|
||||||
|
|
||||||
do_test pager1-3.7.$s.1 {
|
do_test pager1-3.7.$otn.0 {
|
||||||
faultsim_delete_and_reopen
|
faultsim_delete_and_reopen
|
||||||
execsql $sql
|
execsql $sql
|
||||||
execsql {
|
execsql {
|
||||||
@ -241,6 +252,8 @@ foreach code [list {
|
|||||||
set tn 0
|
set tn 0
|
||||||
set lowpoint 0
|
set lowpoint 0
|
||||||
foreach x {
|
foreach x {
|
||||||
|
100 x 0 100
|
||||||
|
x
|
||||||
70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
|
70 22 96 59 96 50 22 56 21 16 37 64 43 40 0 38 22 38 55 0 6
|
||||||
43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
|
43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69
|
||||||
2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
|
2 29 6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43
|
||||||
@ -255,25 +268,13 @@ foreach code [list {
|
|||||||
8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
|
8 41 98 5 60 26 92 29 91 90 2 62 40 4 5 22 80 15 83 76 52 88
|
||||||
29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
|
29 5 68 73 72 7 54 17 89 32 81 94 51 28 53 71 8 42 54 59 70 79
|
||||||
x
|
x
|
||||||
35 59 37 22 8 72 10 48 79 6 87 96 59 95 45 56 6 4 86 68 25 28
|
|
||||||
43 75 47 9 53 18 69 51 11 94 86 65 23 87 49 19 20 20 33 14 11 86
|
|
||||||
42 23 8 40 94 55 4 38 52 30 6 25 44 79 57 82 30 87 86 75 40 92
|
|
||||||
29 26 82 91 67 64 15 51 17 11 15 27 32 7 38 1 52 82 26 99 17 18
|
|
||||||
38 13 20 65 91 98 50 81 49 15 94 45 84 35 31 67 13 43 78 3 94 77
|
|
||||||
47 18 96 66 99 77 11 11 70 18 1 29 79 57 59 86 94 34 91 15 24 53
|
|
||||||
61 73 58 46 36 79 90 89 12 0 91 0 86 44 71 83 75 76 97 65 13 80
|
|
||||||
42 39 15 44 90 18 67 69 1 72 17 99 12 72 77 17 3 34 75 59 92 76
|
|
||||||
18 86 60 12 20 98 48 14 12 67 45 44 10 2 5 88 7 45 5 47 45 75
|
|
||||||
19 25 42 62 66 17 94 63 0 53 38 81 26 11 97 33 13 36 81 82 73 26
|
|
||||||
78 90 28 78 26 61 9 74 70 53 17 86 51 90 3 30 99 5 25 44 6 72
|
|
||||||
84 32 74 46 16 44 74 82 84 9 58 90 85 82 53 40 37
|
|
||||||
} {
|
} {
|
||||||
incr tn
|
incr tn
|
||||||
set now [db one {SELECT count(i) FROM t1}]
|
set now [db one {SELECT count(i) FROM t1}]
|
||||||
if {$x == "x"} {
|
if {$x == "x"} {
|
||||||
execsql { COMMIT ; BEGIN }
|
execsql { COMMIT ; BEGIN }
|
||||||
set lowpoint $now
|
set lowpoint $now
|
||||||
do_test pager1.3.7.$s.2.$tn {
|
do_test pager1.3.7.$otn.$tn {
|
||||||
sqlite3 db2 test.db
|
sqlite3 db2 test.db
|
||||||
execsql {
|
execsql {
|
||||||
SELECT COALESCE(max(i), 0) FROM t1;
|
SELECT COALESCE(max(i), 0) FROM t1;
|
||||||
@ -295,7 +296,7 @@ foreach code [list {
|
|||||||
execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
|
execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
do_execsql_test pager1.3.7.$s.2.$tn {
|
do_execsql_test pager1.3.7.$otn.$tn {
|
||||||
SELECT COALESCE(max(i), 0) FROM t1;
|
SELECT COALESCE(max(i), 0) FROM t1;
|
||||||
PRAGMA integrity_check;
|
PRAGMA integrity_check;
|
||||||
} [list $x ok]
|
} [list $x ok]
|
||||||
@ -316,6 +317,10 @@ tv delete
|
|||||||
# compute) the associated journal is rolled back (and no
|
# compute) the associated journal is rolled back (and no
|
||||||
# xAccess() call to check for the presence of any master
|
# xAccess() call to check for the presence of any master
|
||||||
# journal file is made).
|
# journal file is made).
|
||||||
|
#
|
||||||
|
# pager1.4.3.*: Test that the contents of a hot-journal are ignored if the
|
||||||
|
# page-size or sector-size in the journal header appear to
|
||||||
|
# be invalid (too large, too small or not a power of 2).
|
||||||
#
|
#
|
||||||
do_test pager1.4.1.1 {
|
do_test pager1.4.1.1 {
|
||||||
faultsim_delete_and_reopen
|
faultsim_delete_and_reopen
|
||||||
@ -403,5 +408,48 @@ do_test pager1.4.2.5 {
|
|||||||
}
|
}
|
||||||
} {4 ok}
|
} {4 ok}
|
||||||
|
|
||||||
|
do_test pager1.4.3.1 {
|
||||||
|
testvfs tstvfs -default 1
|
||||||
|
tstvfs filter xSync
|
||||||
|
tstvfs script xSyncCallback
|
||||||
|
proc xSyncCallback {method file args} {
|
||||||
|
set file [file tail $file]
|
||||||
|
if { 0==[string match *journal $file] } { faultsim_save }
|
||||||
|
}
|
||||||
|
faultsim_delete_and_reopen
|
||||||
|
execsql {
|
||||||
|
PRAGMA journal_mode = DELETE;
|
||||||
|
CREATE TABLE t1(a, b);
|
||||||
|
INSERT INTO t1 VALUES(1, 2);
|
||||||
|
INSERT INTO t1 VALUES(3, 4);
|
||||||
|
}
|
||||||
|
db close
|
||||||
|
tstvfs delete
|
||||||
|
} {}
|
||||||
|
|
||||||
|
foreach {tn ofst value result} {
|
||||||
|
2 20 31 {1 2 3 4}
|
||||||
|
3 20 32 {1 2 3 4}
|
||||||
|
4 20 33 {1 2 3 4}
|
||||||
|
5 20 65536 {1 2 3 4}
|
||||||
|
6 20 131072 {1 2 3 4}
|
||||||
|
|
||||||
|
7 24 511 {1 2 3 4}
|
||||||
|
8 24 513 {1 2 3 4}
|
||||||
|
9 24 65536 {1 2 3 4}
|
||||||
|
|
||||||
|
10 32 65536 {1 2}
|
||||||
|
} {
|
||||||
|
do_test pager1.4.3.$tn {
|
||||||
|
faultsim_restore_and_reopen
|
||||||
|
hexio_write test.db-journal $ofst [format %.8x $value]
|
||||||
|
execsql { SELECT * FROM t1 }
|
||||||
|
} $result
|
||||||
|
}
|
||||||
|
db close
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
|
||||||
|
@ -54,11 +54,56 @@ do_faultsim_test pagerfault-1 -prep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Test fault-injection while rolling back a hot-journal file with a
|
||||||
|
# page-size different from the current value stored on page 1 of the
|
||||||
|
# database file.
|
||||||
|
#
|
||||||
|
do_test pagerfault-2-pre1 {
|
||||||
|
testvfs tv -default 1
|
||||||
|
tv filter xSync
|
||||||
|
tv script xSyncCb
|
||||||
|
proc xSyncCb {filename args} {
|
||||||
|
if {[string match *journal filename]==0} faultsim_save
|
||||||
|
}
|
||||||
|
faultsim_delete_and_reopen
|
||||||
|
execsql {
|
||||||
|
PRAGMA page_size = 4096;
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE abc(a, b, c);
|
||||||
|
INSERT INTO abc VALUES('o', 't', 't');
|
||||||
|
INSERT INTO abc VALUES('f', 'f', 's');
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 4
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 8
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 16
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 32
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 64
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 128
|
||||||
|
INSERT INTO abc SELECT * FROM abc; -- 256
|
||||||
|
COMMIT;
|
||||||
|
PRAGMA page_size = 1024;
|
||||||
|
VACUUM;
|
||||||
|
}
|
||||||
|
db close
|
||||||
|
tv delete
|
||||||
|
} {}
|
||||||
|
do_faultsim_test pagerfault-2 -prep {
|
||||||
|
faultsim_restore_and_reopen
|
||||||
|
} -body {
|
||||||
|
execsql { SELECT * FROM abc }
|
||||||
|
} -test {
|
||||||
|
set answer [split [string repeat "ottffs" 128] ""]
|
||||||
|
faultsim_test_result [list 0 $answer]
|
||||||
|
faultsim_integrity_check
|
||||||
|
set res [db eval { SELECT * FROM abc }]
|
||||||
|
if {$res != $answer} { error "Database content appears incorrect ($res)" }
|
||||||
|
} -faults oom-transient
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# Test fault-injection while rolling back hot-journals that were created
|
# Test fault-injection while rolling back hot-journals that were created
|
||||||
# as part of a multi-file transaction.
|
# as part of a multi-file transaction.
|
||||||
#
|
#
|
||||||
do_test pagerfault-2-pre1 {
|
do_test pagerfault-3-pre1 {
|
||||||
testvfs tstvfs -default 1
|
testvfs tstvfs -default 1
|
||||||
tstvfs filter xDelete
|
tstvfs filter xDelete
|
||||||
tstvfs script xDeleteCallback
|
tstvfs script xDeleteCallback
|
||||||
@ -96,7 +141,7 @@ do_test pagerfault-2-pre1 {
|
|||||||
db close
|
db close
|
||||||
tstvfs delete
|
tstvfs delete
|
||||||
} {}
|
} {}
|
||||||
do_faultsim_test pagerfault-2 -faults ioerr-persistent -prep {
|
do_faultsim_test pagerfault-3 -faults ioerr-persistent -prep {
|
||||||
faultsim_restore_and_reopen
|
faultsim_restore_and_reopen
|
||||||
} -body {
|
} -body {
|
||||||
execsql {
|
execsql {
|
||||||
@ -107,7 +152,6 @@ do_faultsim_test pagerfault-2 -faults ioerr-persistent -prep {
|
|||||||
} -test {
|
} -test {
|
||||||
faultsim_test_result {0 {4 4}} {1 {unable to open database: test.db2}}
|
faultsim_test_result {0 {4 4}} {1 {unable to open database: test.db2}}
|
||||||
faultsim_integrity_check
|
faultsim_integrity_check
|
||||||
|
|
||||||
catchsql { ATTACH 'test.db2' AS aux }
|
catchsql { ATTACH 'test.db2' AS aux }
|
||||||
if {[db one { SELECT count(*) FROM t1 }] != 4
|
if {[db one { SELECT count(*) FROM t1 }] != 4
|
||||||
|| [db one { SELECT count(*) FROM t2 }] != 4
|
|| [db one { SELECT count(*) FROM t2 }] != 4
|
||||||
@ -116,4 +160,80 @@ do_faultsim_test pagerfault-2 -faults ioerr-persistent -prep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Test fault-injection as part of a vanilla, no-transaction, INSERT
|
||||||
|
# statement.
|
||||||
|
#
|
||||||
|
do_faultsim_test pagerfault-4 -prep {
|
||||||
|
faultsim_delete_and_reopen
|
||||||
|
} -body {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE x(y);
|
||||||
|
INSERT INTO x VALUES('z');
|
||||||
|
SELECT * FROM x;
|
||||||
|
}
|
||||||
|
} -test {
|
||||||
|
faultsim_test_result {0 z}
|
||||||
|
faultsim_integrity_check
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Test fault-injection as part of a commit when using journal_mode=PERSIST.
|
||||||
|
#
|
||||||
|
do_test pagerfault-5-pre1 {
|
||||||
|
faultsim_delete_and_reopen
|
||||||
|
db func a_string a_string
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE t1(a UNIQUE, b UNIQUE);
|
||||||
|
INSERT INTO t1 VALUES(a_string(200), a_string(300));
|
||||||
|
INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
|
||||||
|
}
|
||||||
|
faultsim_save_and_close
|
||||||
|
} {}
|
||||||
|
do_faultsim_test pagerfault-5.1 -prep {
|
||||||
|
faultsim_restore_and_reopen
|
||||||
|
db func a_string a_string
|
||||||
|
execsql { PRAGMA journal_mode = PERSIST }
|
||||||
|
} -body {
|
||||||
|
execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
|
||||||
|
} -test {
|
||||||
|
faultsim_test_result {0 {}}
|
||||||
|
faultsim_integrity_check
|
||||||
|
}
|
||||||
|
do_faultsim_test pagerfault-5.2 -prep {
|
||||||
|
faultsim_restore_and_reopen
|
||||||
|
db func a_string a_string
|
||||||
|
execsql {
|
||||||
|
PRAGMA journal_mode = PERSIST;
|
||||||
|
PRAGMA journal_size_limit = 2048;
|
||||||
|
}
|
||||||
|
} -body {
|
||||||
|
execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }
|
||||||
|
} -test {
|
||||||
|
faultsim_test_result {0 {}}
|
||||||
|
faultsim_integrity_check
|
||||||
|
}
|
||||||
|
|
||||||
|
do_faultsim_test pagerfault-5.3 -prep {
|
||||||
|
faultsim_restore_and_reopen
|
||||||
|
db func a_string a_string
|
||||||
|
file delete -force test2.db test2.db-journal test2.db-wal
|
||||||
|
execsql {
|
||||||
|
PRAGMA journal_mode = PERSIST;
|
||||||
|
ATTACH 'test2.db' AS aux;
|
||||||
|
PRAGMA aux.journal_mode = PERSIST;
|
||||||
|
PRAGMA aux.journal_size_limit = 0;
|
||||||
|
}
|
||||||
|
} -body {
|
||||||
|
execsql {
|
||||||
|
BEGIN;
|
||||||
|
INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;
|
||||||
|
CREATE TABLE aux.t2 AS SELECT * FROM t1;
|
||||||
|
COMMIT;
|
||||||
|
}
|
||||||
|
} -test {
|
||||||
|
faultsim_test_result {0 {}}
|
||||||
|
}
|
||||||
|
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user