Another test case to test a specific kind of database corruption. (CVS 5352)
FossilOrigin-Name: 38e04d67635d49661f9b95338fc1cb8197bf0bc7
This commit is contained in:
+50
-2
@@ -13,7 +13,7 @@
|
||||
# This file implements tests to make sure SQLite does not crash or
|
||||
# segfault if it sees a corrupt database file.
|
||||
#
|
||||
# $Id: corrupt2.test,v 1.6 2008/07/07 15:39:11 danielk1977 Exp $
|
||||
# $Id: corrupt2.test,v 1.7 2008/07/07 17:04:23 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -169,7 +169,55 @@ do_test corrupt2-3.1 {
|
||||
catchsql {
|
||||
DROP TABLE t1;
|
||||
} db2
|
||||
} {1 {malformed database schema (a3) - index a3 already exists}}
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
do_test corrupt2-4.1 {
|
||||
file delete -force corrupt.db
|
||||
file delete -force corrupt.db-journal
|
||||
sqlite3 db2 corrupt.db
|
||||
|
||||
execsql {
|
||||
PRAGMA page_size = 1024;
|
||||
CREATE TABLE t1(a, b, c);
|
||||
CREATE TABLE t2(a, b, c);
|
||||
INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t2 SELECT * FROM t2;
|
||||
INSERT INTO t1 SELECT * FROM t2;
|
||||
} db2
|
||||
|
||||
db2 close
|
||||
|
||||
# This block links a page from table t2 into the t1 table structure.
|
||||
#
|
||||
set fd [open corrupt.db r+]
|
||||
fconfigure $fd -encoding binary -translation binary
|
||||
seek $fd [expr 1024 + 12]
|
||||
set zCelloffset [read $fd 2]
|
||||
binary scan $zCelloffset S iCelloffset
|
||||
seek $fd [expr 1024 + $iCelloffset]
|
||||
set zChildPage [read $fd 4]
|
||||
seek $fd [expr 2*1024 + 12]
|
||||
set zCelloffset [read $fd 2]
|
||||
binary scan $zCelloffset S iCelloffset
|
||||
seek $fd [expr 2*1024 + $iCelloffset]
|
||||
puts -nonewline $fd $zChildPage
|
||||
close $fd
|
||||
|
||||
sqlite3 db2 corrupt.db
|
||||
db2 eval {SELECT rowid FROM t1} {
|
||||
set result [db2 eval {pragma integrity_check}]
|
||||
break
|
||||
}
|
||||
set result
|
||||
} {{*** in database main ***
|
||||
Page 10: sqlite3BtreeInitPage() returns error code 11
|
||||
On tree page 3 cell 1: Child page depth differs
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user