Smaller and faster PRAGMA integrity_check that also does a better job of
detecting errors. Some output text describing discovered file corruption has changed for clarity. FossilOrigin-Name: 251a7590ff4f65f59a1c871892533e4e2c544515
This commit is contained in:
@@ -249,7 +249,6 @@ do_test corrupt2-5.1 {
|
||||
set result
|
||||
} {{*** in database main ***
|
||||
On tree page 2 cell 0: 2nd reference to page 10
|
||||
On tree page 2 cell 1: Child page depth differs
|
||||
Page 4 is never used}}
|
||||
|
||||
db2 close
|
||||
|
||||
+14
-35
@@ -65,41 +65,20 @@ integrity_check corrupt7-1.4
|
||||
|
||||
# Deliberately corrupt some of the cell offsets in the btree page
|
||||
# on page 2 of the database.
|
||||
#
|
||||
# The error message is different depending on whether or not the
|
||||
# SQLITE_ENABLE_OVERSIZE_CELL_CHECK compile-time option is engaged.
|
||||
#
|
||||
ifcapable oversize_cell_check {
|
||||
do_test corrupt7-2.1 {
|
||||
db close
|
||||
hexio_write test.db 1062 FF
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
Page 2: btreeInitPage() returns error code 11}}
|
||||
do_test corrupt7-2.2 {
|
||||
db close
|
||||
hexio_write test.db 1062 04
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
Page 2: btreeInitPage() returns error code 11}}
|
||||
} else {
|
||||
do_test corrupt7-2.1 {
|
||||
db close
|
||||
hexio_write test.db 1062 FF
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
Corruption detected in cell 15 on page 2}}
|
||||
do_test corrupt7-2.2 {
|
||||
db close
|
||||
hexio_write test.db 1062 04
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
On tree page 2 cell 15: Rowid 0 out of order (previous was 15)}}
|
||||
}
|
||||
do_test corrupt7-2.1 {
|
||||
db close
|
||||
hexio_write test.db 1062 FF
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
On tree page 2 cell 15: Offset 65457 out of range 945..1020}}
|
||||
do_test corrupt7-2.2 {
|
||||
db close
|
||||
hexio_write test.db 1062 04
|
||||
sqlite3 db test.db
|
||||
db eval {PRAGMA integrity_check(1)}
|
||||
} {{*** in database main ***
|
||||
On tree page 2 cell 15: Offset 1201 out of range 945..1020}}
|
||||
|
||||
# The code path that was causing the buffer overrun that this test
|
||||
# case was checking for was removed.
|
||||
|
||||
+10
-36
@@ -14,7 +14,6 @@
|
||||
# segfault if it sees a corrupt database file. It specifcally
|
||||
# focuses on rowid order corruption.
|
||||
#
|
||||
# $Id: corruptE.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -79,12 +78,8 @@ do_test corruptE-2.1 {
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
set res [ catchsql {PRAGMA integrity_check} ]
|
||||
set ans [lindex $res 1]
|
||||
|
||||
list [regexp {out of order.*previous was} $ans] \
|
||||
[regexp {out of order.*max larger than parent max} $ans]
|
||||
} {1 1}
|
||||
catchsql {PRAGMA integrity_check}
|
||||
} {/ out of order/}
|
||||
|
||||
do_test corruptE-2.2 {
|
||||
db close
|
||||
@@ -95,12 +90,8 @@ do_test corruptE-2.2 {
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
set res [ catchsql {PRAGMA integrity_check} ]
|
||||
set ans [lindex $res 1]
|
||||
|
||||
list [regexp {out of order.*previous was} $ans] \
|
||||
[regexp {out of order.*min less than parent min} $ans]
|
||||
} {1 1}
|
||||
catchsql {PRAGMA integrity_check}
|
||||
} {/ Extends off end of page/}
|
||||
|
||||
do_test corruptE-2.3 {
|
||||
db close
|
||||
@@ -112,11 +103,8 @@ do_test corruptE-2.3 {
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
set res [ catchsql {PRAGMA integrity_check} ]
|
||||
set ans [lindex $res 1]
|
||||
|
||||
list [regexp {out of order.*max larger than parent min} $ans]
|
||||
} {1}
|
||||
catchsql {PRAGMA integrity_check}
|
||||
} {/out of order/}
|
||||
|
||||
do_test corruptE-2.4 {
|
||||
db close
|
||||
@@ -127,33 +115,22 @@ do_test corruptE-2.4 {
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
set res [ catchsql {PRAGMA integrity_check} ]
|
||||
set ans [lindex $res 1]
|
||||
|
||||
list [regexp {out of order.*min less than parent max} $ans]
|
||||
} {1}
|
||||
catchsql {PRAGMA integrity_check}
|
||||
} {/out of order/}
|
||||
|
||||
|
||||
set tests [list {10233 0xd0} \
|
||||
{941 0x42} \
|
||||
{1028 0x53} \
|
||||
{2041 0xd0} \
|
||||
{2042 0x1f} \
|
||||
{2047 0xaa} \
|
||||
{2263 0x29} \
|
||||
{2274 0x75} \
|
||||
{3267 0xf2} \
|
||||
{4104 0x2c} \
|
||||
{5113 0x36} \
|
||||
{10233 0x84} \
|
||||
{10234 0x74} \
|
||||
{10239 0x41} \
|
||||
{10453 0x11} \
|
||||
{11273 0x28} \
|
||||
{11455 0x11} \
|
||||
{11461 0xe6} \
|
||||
{12281 0x99} \
|
||||
{12296 0x9e} \
|
||||
{12297 0xd7} \
|
||||
{13303 0x53} ]
|
||||
|
||||
@@ -168,11 +145,8 @@ foreach test $tests {
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
set res [ catchsql {PRAGMA integrity_check} ]
|
||||
set ans [lindex $res 1]
|
||||
|
||||
list [regexp {out of order} $ans]
|
||||
} {1}
|
||||
catchsql {PRAGMA integrity_check}
|
||||
} {/out of order/}
|
||||
incr tc 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user