Add tests to pager1.test and pagerfault.test.

FossilOrigin-Name: c6e75950928954fbb1590f952e3cdbcb0753b745
This commit is contained in:
dan 2010-07-01 19:01:56 +00:00
parent 89ccf4481b
commit d0b0d4dc23
4 changed files with 253 additions and 34 deletions

View File

@ -1,5 +1,5 @@
C Add\spager\stest\scases.\sChange\sa\scondition\sin\spager.c\sto\sNEVER().
D 2010-07-01T15:09:48
C Add\stests\sto\spager1.test\sand\spagerfault.test.
D 2010-07-01T19:01:56
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -535,9 +535,9 @@ F test/notify3.test b923ff67728f363378698fb27b5f41a5a1b4d9e0
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
F test/pager1.test f00c701b29a37a08f084a0183b4901a3a57e6673
F test/pager1.test 67de7de48695203bab435eca9e650fb5ec634da6
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
F test/pagerfault.test 6d5bf244d171e808e3b642ab830f5cd159af8f7b
F test/pagerfault.test 6ece6ceb6384e90ec526a65c4f4e8cd9b6dc7d61
F test/pagerfault2.test 1287f123bd5d20452113739ed7755fd254e502f1
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
@ -829,7 +829,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 8e65c0e3dac400f6a0ec3b7494fba62c14ed6182
R ce36b405629391c76b6369dbfd427fc7
P a8f6341d3b12d64ef56ed05226e3b4f183b8957d
R b06840e637f43962c2afd5444d532e11
U dan
Z 6dd5024e4de43ce2f67cf29dfaba34f2
Z fe3e1bcbb9bcaec1df9d747e7acac3b7

View File

@ -1 +1 @@
a8f6341d3b12d64ef56ed05226e3b4f183b8957d
c6e75950928954fbb1590f952e3cdbcb0753b745

View File

@ -1223,6 +1223,15 @@ do_test pager1-9.2.4 { execsql { SELECT count(*) FROM ab } } {128}
db close
db2 close
proc recursive_select {id table {script {}}} {
set cnt 0
db eval "SELECT rowid, * FROM $table WHERE rowid = ($id-1)" {
recursive_select $rowid $table $script
incr cnt
}
if {$cnt==0} { eval $script }
}
#-------------------------------------------------------------------------
# Test that regardless of the value returned by xSectorSize(), the
# minimum effective sector-size is 512 and the maximum 65536 bytes.
@ -1237,16 +1246,100 @@ foreach sectorsize {
if {$sectorsize < 512} { set eff 512 }
if {$sectorsize > 65536} { set eff 65536 }
do_test pager1-10.$sectorsize {
do_test pager1-10.$sectorsize.1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA journal_mode = PERSIST;
PRAGMA page_size = 1024;
CREATE TABLE t1(a, b);
BEGIN;
CREATE TABLE t1(a, b);
CREATE TABLE t2(a, b);
CREATE TABLE t3(a, b);
COMMIT;
}
file size test.db-journal
} [expr $sectorsize > 65536 ? 65536 : $sectorsize]
do_test pager1-10.$sectorsize.2 {
execsql {
INSERT INTO t3 VALUES(a_string(300), a_string(300));
INSERT INTO t3 SELECT * FROM t3; /* 2 */
INSERT INTO t3 SELECT * FROM t3; /* 4 */
INSERT INTO t3 SELECT * FROM t3; /* 8 */
INSERT INTO t3 SELECT * FROM t3; /* 16 */
INSERT INTO t3 SELECT * FROM t3; /* 32 */
}
} {}
do_test pager1-10.$sectorsize.3 {
db close
sqlite3 db test.db
execsql {
PRAGMA cache_size = 10;
BEGIN;
}
recursive_select 32 t3 {db eval "INSERT INTO t2 VALUES(1, 2)"}
execsql {
COMMIT;
SELECT * FROM t2;
}
} {1 2}
do_test pager1-10.$sectorsize.4 {
execsql {
CREATE TABLE t6(a, b);
CREATE TABLE t7(a, b);
CREATE TABLE t5(a, b);
DROP TABLE t6;
DROP TABLE t7;
}
if {$eff==65536} breakpoint
execsql {
BEGIN;
CREATE TABLE t6(a, b);
}
recursive_select 32 t3 {db eval "INSERT INTO t5 VALUES(1, 2)"}
execsql {
COMMIT;
SELECT * FROM t5;
}
} {1 2}
}
db close
tv sectorsize 4096
do_test pager1.10.x.1 {
faultsim_delete_and_reopen
execsql {
PRAGMA page_size = 1024;
CREATE TABLE t1(x);
}
for {set i 0} {$i<30} {incr i} {
execsql { INSERT INTO t1 VALUES(zeroblob(900)) }
}
file size test.db
} {32768}
do_test pager1.10.x.2 {
execsql {
CREATE TABLE t2(x);
DROP TABLE t2;
}
file size test.db
} {33792}
do_test pager1.10.x.3 {
execsql {
BEGIN;
CREATE TABLE t2(x);
}
recursive_select 30 t1
execsql {
CREATE TABLE t3(x);
COMMIT;
}
} {}
db close
tv delete
@ -1800,7 +1893,6 @@ do_test pager1-21.1 {
db2 close
tv delete
do_test pager1-21.2 {
breakpoint
testvfs tv -iversion 1
sqlite3 db2 test.db -vfs tv
catchsql { SELECT * FROM ko } db2
@ -1857,6 +1949,10 @@ tv delete
# pager1-23.5.*: Try to set various different journal modes with an
# in-memory database (only MEMORY and OFF should work).
#
# pager1-23.6.*: Try to set locking_mode=normal on an in-memory database
# (doesn't work - in-memory databases always use
# locking_mode=exclusive).
#
do_test pager1-23.1.1 {
faultsim_delete_and_reopen
execsql {
@ -1937,19 +2033,110 @@ foreach {tn mode possible} {
execsql "PRAGMA journal_mode = $mode"
} [if $possible {list $mode} {list memory}]
}
do_test pager1-23.8.1 {
do_test pager1-23.6.1 {
execsql {PRAGMA locking_mode = normal}
} {exclusive}
do_test pager1-23.8.2 {
do_test pager1-23.6.2 {
execsql {PRAGMA locking_mode = exclusive}
} {exclusive}
do_test pager1-23.8.3 {
do_test pager1-23.6.3 {
execsql {PRAGMA locking_mode}
} {exclusive}
do_test pager1-23.8.4 {
do_test pager1-23.6.4 {
execsql {PRAGMA main.locking_mode}
} {exclusive}
#-------------------------------------------------------------------------
#
do_test pager1-24.1.1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA cache_size = 10;
PRAGMA auto_vacuum = FULL;
CREATE TABLE x1(x, y, z, PRIMARY KEY(y, z));
CREATE TABLE x2(x, y, z, PRIMARY KEY(y, z));
INSERT INTO x2 VALUES(a_string(400), a_string(500), a_string(600));
INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;
INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;
INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;
INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;
INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;
INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;
INSERT INTO x1 SELECT * FROM x2;
}
} {}
proc recursive_select {id {script {}}} {
set cnt 0
db eval {SELECT rowid, x,y,z FROM x2 WHERE rowid = ($id-1)} {
recursive_select $rowid $script
incr cnt
}
if {$cnt==0} { eval $script }
}
do_test pager1-24.1.2 {
execsql {
BEGIN;
DELETE FROM x1 WHERE rowid<32;
}
recursive_select 64
} {}
do_test pager1-24.1.3 {
execsql {
UPDATE x1 SET z = a_string(300) WHERE rowid>40;
COMMIT;
PRAGMA integrity_check;
SELECT count(*) FROM x1;
}
} {ok 33}
do_test pager1-24.1.4 {
execsql {
DELETE FROM x1;
INSERT INTO x1 SELECT * FROM x2;
BEGIN;
DELETE FROM x1 WHERE rowid<32;
UPDATE x1 SET z = a_string(299) WHERE rowid>40;
}
recursive_select 64 {db eval COMMIT}
execsql {
PRAGMA integrity_check;
SELECT count(*) FROM x1;
}
} {ok 33}
do_test pager1-24.1.5 {
execsql {
DELETE FROM x1;
INSERT INTO x1 SELECT * FROM x2;
}
recursive_select 64 { db eval {CREATE TABLE x3(x, y, z)} }
execsql { SELECT * FROM x3 }
} {}
#-------------------------------------------------------------------------
#
do_test pager1-25-1 {
faultsim_delete_and_reopen
execsql {
BEGIN;
SAVEPOINT abc;
CREATE TABLE t1(a, b);
ROLLBACK TO abc;
COMMIT;
}
db close
} {}
breakpoint
do_test pager1-25-2 {
faultsim_delete_and_reopen
execsql {
SAVEPOINT abc;
CREATE TABLE t1(a, b);
ROLLBACK TO abc;
COMMIT;
}
db close
} {}
finish_test

View File

@ -614,7 +614,6 @@ do_faultsim_test pagerfault-13 -prep {
faultsim_test_result {0 {}}
}
#---------------------------------------------------------------------------
# Test fault injection into a small backup operation.
#
@ -655,6 +654,24 @@ do_faultsim_test pagerfault-14b -prep {
} -test {
faultsim_test_result {0 {}}
}
do_faultsim_test pagerfault-14c -prep {
faultsim_restore_and_reopen
sqlite3 db2 test.db2
db2 eval {
PRAGMA synchronous = off;
PRAGMA page_size = 4096;
CREATE TABLE xx(a);
}
} -body {
sqlite3_backup B db2 main db main
B step 200
set rc [B finish]
if {[string match SQLITE_IOERR_* $rc]} {set rc SQLITE_IOERR}
if {$rc != "SQLITE_OK"} { error [sqlite3_test_errstr $rc] }
set {} {}
} -test {
faultsim_test_result {0 {}}
}
do_test pagerfault-15-pre1 {
faultsim_delete_and_reopen
@ -819,8 +836,6 @@ do_faultsim_test pagerfault-18 -prep {
faultsim_integrity_check
}
}
do_faultsim_test pagerfault-19a -prep {
sqlite3 db :memory:
db func a_string a_string
@ -875,36 +890,53 @@ do_faultsim_test pagerfault-19b -prep {
faultsim_test_result {0 {3 5 7}}
}
#-------------------------------------------------------------------------
# This tests fault-injection in a special case in the auto-vacuum code.
#
do_test pagerfault-20-pre1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
CREATE TABLE x1(x, y, z, PRIMARY KEY(y, z));
INSERT INTO x1 VALUES(a_string(400), a_string(500), a_string(600));
INSERT INTO x1 SELECT a_string(600), a_string(400), a_string(500) FROM x1;
INSERT INTO x1 SELECT a_string(500), a_string(600), a_string(400) FROM x1;
INSERT INTO x1 SELECT a_string(400), a_string(500), a_string(600) FROM x1;
INSERT INTO x1 SELECT a_string(600), a_string(400), a_string(500) FROM x1;
INSERT INTO x1 SELECT a_string(500), a_string(600), a_string(400) FROM x1;
INSERT INTO x1 SELECT a_string(400), a_string(500), a_string(600) FROM x1;
PRAGMA cache_size = 10;
PRAGMA auto_vacuum = FULL;
CREATE TABLE t0(a, b);
}
faultsim_save_and_close
} {}
do_faultsim_test pagerfault-20 -prep {
faultsim_restore_and_reopen
db func a_string a_string
} -body {
execsql {
BEGIN;
UPDATE x1 SET z = a_string(300);
DELETE FROM x1 WHERE rowid<32;
CREATE TABLE t1(a, b);
CREATE TABLE t2(a, b);
DROP TABLE t1;
COMMIT;
}
} -test {
faultsim_test_result {0 {}}
faultsim_integrity_check
set nRow [db one {SELECT count(*) FROM x1}]
if {$nRow!=33 && $nRow!=64} {error "Wrong number of rows $nRow"}
}
do_test pagerfault-21-pre1 {
faultsim_delete_and_reopen
execsql {
PRAGMA cache_size = 10;
CREATE TABLE t0(a PRIMARY KEY, b);
INSERT INTO t0 VALUES(1, 2);
}
faultsim_save_and_close
} {}
do_faultsim_test pagerfault-21 -prep {
faultsim_restore_and_reopen
} -body {
db eval { SELECT * FROM t0 LIMIT 1 } {
db eval { INSERT INTO t0 SELECT a+1, b FROM t0 }
db eval { INSERT INTO t0 SELECT a+2, b FROM t0 }
}
} -test {
faultsim_test_result {0 {}}
}
}
finish_test