Add test case for the obscure corruption detection added by the previous commit.

FossilOrigin-Name: f221f31efff83651b9af295b98cfe98bcba3ad54
This commit is contained in:
dan 2009-12-05 18:16:11 +00:00
parent 89e060e462
commit d1f7e92624
4 changed files with 62 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Catch\san\sobscure\scase\sof\sdatabase\scorruption.
D 2009-12-05T18:03:51
C Add\stest\scase\sfor\sthe\sobscure\scorruption\sdetection\sadded\sby\sthe\sprevious\scommit.
D 2009-12-05T18:16:11
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -290,7 +290,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6
F test/colmeta.test 087c42997754b8c648819832241daf724f813322
F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b
F test/conflict.test 0ed68b11f22721052d880ee80bd528a0e0828236
F test/corrupt.test f47f220959b40f79f30c4271eefcec0587e984e3
F test/corrupt.test 85c3fececa01bc6d24ff5d7bf1373844840c0b98
F test/corrupt2.test a571e30ea4e82318f319a24b6cc55935ce862079
F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
@ -402,7 +402,7 @@ F test/fts3expr.test 05dab77387801e4900009917bb18f556037d82da
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
F test/fts3malloc.test d02ee86b21edd2b43044e0d6dfdcd26cb6efddcb
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
F test/fts3rnd.test 151071849c9db2bade6e3d3c0c20e3a8f4f30892
F test/fts3rnd.test 351197c4459c9d0a20e6413e5bc541a0dbfc4765
F test/func.test af106ed834001738246d276659406823e35cde7b
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/fuzz.test a4174c3009a3e2c2e14b31b364ebf7ddb49de2c9
@ -776,7 +776,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 3bb13a06521b54194c9f3eb44e0dc42bacf016a4
R c1a926ab37f61c0c2b02b1d3be3199ea
P 0f9b17a6da42b4da667bbbc00f713effe92a66b5
R fb94845ed98c394aab22f4eeec2551a7
U dan
Z dce477f25b7ac265ef79fd810e61cc32
Z a0458738b3e670f2ae299b61dcf4c17d

View File

@ -1 +1 @@
0f9b17a6da42b4da667bbbc00f713effe92a66b5
f221f31efff83651b9af295b98cfe98bcba3ad54

View File

@ -257,4 +257,58 @@ do_test corrupt-6.1 {
catchsql { INSERT INTO t1 VALUES( randomblob(10) ) }
} {1 {database disk image is malformed}}
ifcapable oversize_cell_check {
db close
file delete -force test.db test.db-journal
sqlite3 db test.db
execsql {
PRAGMA page_size = 1024; CREATE TABLE t1(x);
}
do_test corrupt-7.1 {
for {set i 0} {$i < 39} {incr i} {
execsql {
INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');
}
}
} {}
db close
# Corrupt the root page of table t1 so that the first offset in the
# cell-offset array points to the data for the SQL blob associated with
# record (rowid=10). The root page still passes the checks in btreeInitPage(),
# because the start of said blob looks like the start of a legitimate
# page cell.
#
# Test case cc-2 overwrites the blob so that it no longer looks like a
# real cell. But, by the time it is overwritten, btreeInitPage() has already
# initialized the root page, so no corruption is detected.
#
# Test case cc-3 inserts an extra record into t1, forcing balance-deeper
# to run. After copying the contents of the root page to the new child,
# btreeInitPage() is called on the child. This time, it detects corruption
# (because the start of the blob associated with the (rowid=10) record
# no longer looks like a real cell). At one point the code assumed that
# detecting corruption was not possible at that point, and an assert() failed.
#
set fd [open test.db r+]
fconfigure $fd -translation binary -encoding binary
seek $fd [expr 1024+8]
puts -nonewline $fd "\x03\x14"
close $fd
sqlite3 db test.db
do_test corrupt-7.2 {
execsql {
UPDATE t1 SET x = X'870400020003000400050006000700080009000A'
WHERE rowid = 10;
}
} {}
do_test corrupt-7.3 {
catchsql {
INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');
}
} {1 {database disk image is malformed}}
}
finish_test

View File

@ -218,7 +218,6 @@ foreach nodesize {50 500 1000 2000} {
do_test fts3rnd-1.$nodesize.$iTest.5.$i.$match {
execsql { SELECT docid FROM t1 WHERE t1 MATCH $match }
} [simple_near $terms $nNear]
if {$::nErr} {exit -1}
}
}
}