3 more coverage tests for btree.c. (CVS 5370)
FossilOrigin-Name: 96df0a5fa4bb2b3dfedf034d81704e152cdc63a9
This commit is contained in:
+30
-1
@@ -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.11 2008/07/08 14:31:15 danielk1977 Exp $
|
||||
# $Id: corrupt2.test,v 1.12 2008/07/08 15:59:52 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -336,6 +336,7 @@ ifcapable autovacuum {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
corruption_test -sqlprep {
|
||||
PRAGMA page_size = 1024;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
@@ -365,4 +366,32 @@ corruption_test -sqlprep {
|
||||
} {1 {database disk image is malformed}}
|
||||
}
|
||||
|
||||
corruption_test -sqlprep {
|
||||
CREATE TABLE t1(a, b, c); CREATE TABLE t8(a, b, c); CREATE TABLE tE(a, b, c);
|
||||
CREATE TABLE t2(a, b, c); CREATE TABLE t9(a, b, c); CREATE TABLE tF(a, b, c);
|
||||
CREATE TABLE t3(a, b, c); CREATE TABLE tA(a, b, c); CREATE TABLE tG(a, b, c);
|
||||
CREATE TABLE t4(a, b, c); CREATE TABLE tB(a, b, c); CREATE TABLE tH(a, b, c);
|
||||
CREATE TABLE t5(a, b, c); CREATE TABLE tC(a, b, c); CREATE TABLE tI(a, b, c);
|
||||
CREATE TABLE t6(a, b, c); CREATE TABLE tD(a, b, c); CREATE TABLE tJ(a, b, c);
|
||||
CREATE TABLE x1(a, b, c); CREATE TABLE x8(a, b, c); CREATE TABLE xE(a, b, c);
|
||||
CREATE TABLE x2(a, b, c); CREATE TABLE x9(a, b, c); CREATE TABLE xF(a, b, c);
|
||||
CREATE TABLE x3(a, b, c); CREATE TABLE xA(a, b, c); CREATE TABLE xG(a, b, c);
|
||||
CREATE TABLE x4(a, b, c); CREATE TABLE xB(a, b, c); CREATE TABLE xH(a, b, c);
|
||||
CREATE TABLE x5(a, b, c); CREATE TABLE xC(a, b, c); CREATE TABLE xI(a, b, c);
|
||||
CREATE TABLE x6(a, b, c); CREATE TABLE xD(a, b, c); CREATE TABLE xJ(a, b, c);
|
||||
} -corrupt {
|
||||
set fd [open corrupt.db r+]
|
||||
fconfigure $fd -translation binary -encoding binary
|
||||
seek $fd 108
|
||||
set zRightChild [read $fd 4]
|
||||
binary scan $zRightChild I iRightChild
|
||||
seek $fd [expr 1024*($iRightChild-1)+3]
|
||||
puts -nonewline $fd "\x00\x00"
|
||||
close $fd
|
||||
} -test {
|
||||
do_test corrupt2-8.1 {
|
||||
catchsql { SELECT sql FROM sqlite_master }
|
||||
} {1 {database disk image is malformed}}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+21
-1
@@ -29,7 +29,7 @@
|
||||
# The solution to the problem was to detect that the table is locked
|
||||
# before the index entry is deleted.
|
||||
#
|
||||
# $Id: delete2.test,v 1.7 2006/08/16 16:42:48 drh Exp $
|
||||
# $Id: delete2.test,v 1.8 2008/07/08 15:59:52 danielk1977 Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@@ -96,4 +96,24 @@ do_test delete2-1.11 {
|
||||
}
|
||||
} {goodbye id.2 again id.3}
|
||||
|
||||
do_test delete2-2.1 {
|
||||
execsql {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(c, d);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t2 VALUES(3, 4);
|
||||
INSERT INTO t2 VALUES(5, 6);
|
||||
}
|
||||
} {}
|
||||
do_test delete2-2.2 {
|
||||
set res [list]
|
||||
db eval {
|
||||
SELECT CASE WHEN c = 5 THEN b ELSE NULL END AS b, c, d FROM t1, t2
|
||||
} {
|
||||
db eval {DELETE FROM t1}
|
||||
lappend res $b $c $d
|
||||
}
|
||||
set res
|
||||
} {{} 3 4 {} 5 6}
|
||||
|
||||
finish_test
|
||||
|
||||
+20
-1
@@ -15,7 +15,7 @@
|
||||
# The tests in this file use special facilities that are only
|
||||
# available in the SQLite test fixture.
|
||||
#
|
||||
# $Id: ioerr2.test,v 1.7 2008/03/07 19:51:15 drh Exp $
|
||||
# $Id: ioerr2.test,v 1.8 2008/07/08 15:59:52 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -112,4 +112,23 @@ foreach bPersist [list 0 1] {
|
||||
}
|
||||
}
|
||||
|
||||
do_test ioerr2-5 {
|
||||
execsql {
|
||||
CREATE TABLE t2 AS SELECT * FROM t1;
|
||||
}
|
||||
set ::sqlite_io_error_persist 0
|
||||
set ::go 1
|
||||
set rc [catch {
|
||||
for {set ::N 1} {$::N<200} {incr ::N} {
|
||||
db eval {SELECT * FROM t1 WHERE rowid IN (1, 5, 10, 15, 20)} {
|
||||
set ::sqlite_io_error_hit 0
|
||||
set ::sqlite_io_error_pending $::N
|
||||
set sql {UPDATE t2 SET b = randstr(400,400)}
|
||||
foreach {::go res} [catchsql $sql] {}
|
||||
}
|
||||
}
|
||||
} msg]
|
||||
list $rc $msg
|
||||
} {1 {callback requested query abort}}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user