Additional test cases to cover branches in pager.c.
FossilOrigin-Name: eddfb2b4062f8a8b907f0c7bc08a05c16692e900
This commit is contained in:
+83
-25
@@ -59,6 +59,15 @@ do_not_use_codec
|
||||
# requests an invalid page number (due to db corruption).
|
||||
#
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
set a_string_counter 1
|
||||
proc a_string {n} {
|
||||
global a_string_counter
|
||||
@@ -1223,14 +1232,35 @@ 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 }
|
||||
}
|
||||
do_test pager1-9.3.1 {
|
||||
testvfs tv -default 1
|
||||
tv sectorsize 4096
|
||||
faultsim_delete_and_reopen
|
||||
|
||||
execsql { PRAGMA page_size = 1024 }
|
||||
for {set ii 0} {$ii < 4} {incr ii} { execsql "CREATE TABLE t${ii}(a, b)" }
|
||||
} {}
|
||||
do_test pager1-9.3.2 {
|
||||
sqlite3 db2 test.db2
|
||||
execsql {
|
||||
PRAGMA page_size = 4096;
|
||||
PRAGMA synchronous = OFF;
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(a, b);
|
||||
} db2
|
||||
|
||||
sqlite3_backup B db2 main db main
|
||||
B step 30
|
||||
list [B step 10000] [B finish]
|
||||
} {SQLITE_DONE SQLITE_OK}
|
||||
do_test pager1-9.3.3 {
|
||||
db2 close
|
||||
db close
|
||||
tv delete
|
||||
file size test.db2
|
||||
} [file size test.db]
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that regardless of the value returned by xSectorSize(), the
|
||||
@@ -1858,16 +1888,11 @@ do_test pager1-20.3.1 {
|
||||
}
|
||||
} {wal}
|
||||
do_test pager1-20.3.2 {
|
||||
proc recursive_select {id} {
|
||||
db eval {SELECT rowid, x FROM t1 WHERE rowid = ($id-1)} {
|
||||
recursive_select $rowid
|
||||
}
|
||||
}
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO t2 VALUES('xxxx');
|
||||
}
|
||||
recursive_select 32
|
||||
recursive_select 32 t1
|
||||
execsql COMMIT
|
||||
} {}
|
||||
|
||||
@@ -2066,20 +2091,12 @@ do_test pager1-24.1.1 {
|
||||
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
|
||||
recursive_select 64 x2
|
||||
} {}
|
||||
do_test pager1-24.1.3 {
|
||||
execsql {
|
||||
@@ -2098,7 +2115,7 @@ do_test pager1-24.1.4 {
|
||||
DELETE FROM x1 WHERE rowid<32;
|
||||
UPDATE x1 SET z = a_string(299) WHERE rowid>40;
|
||||
}
|
||||
recursive_select 64 {db eval COMMIT}
|
||||
recursive_select 64 x2 {db eval COMMIT}
|
||||
execsql {
|
||||
PRAGMA integrity_check;
|
||||
SELECT count(*) FROM x1;
|
||||
@@ -2110,7 +2127,7 @@ do_test pager1-24.1.5 {
|
||||
DELETE FROM x1;
|
||||
INSERT INTO x1 SELECT * FROM x2;
|
||||
}
|
||||
recursive_select 64 { db eval {CREATE TABLE x3(x, y, z)} }
|
||||
recursive_select 64 x2 { db eval {CREATE TABLE x3(x, y, z)} }
|
||||
execsql { SELECT * FROM x3 }
|
||||
} {}
|
||||
|
||||
@@ -2139,4 +2156,45 @@ do_test pager1-25-2 {
|
||||
db close
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Sector-size tests.
|
||||
#
|
||||
do_test pager1-26.1 {
|
||||
testvfs tv -default 1
|
||||
tv sectorsize 4096
|
||||
faultsim_delete_and_reopen
|
||||
db func a_string a_string
|
||||
execsql {
|
||||
PRAGMA page_size = 512;
|
||||
CREATE TABLE tbl(a PRIMARY KEY, b UNIQUE);
|
||||
BEGIN;
|
||||
INSERT INTO tbl VALUES(a_string(25), a_string(600));
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_execsql_test pager1-26.1 {
|
||||
UPDATE tbl SET b = a_string(550);
|
||||
} {}
|
||||
db close
|
||||
tv delete
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
do_test pager1.27.1 {
|
||||
faultsim_delete_and_reopen
|
||||
sqlite3_pager_refcounts db
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a, b);
|
||||
}
|
||||
sqlite3_pager_refcounts db
|
||||
execsql COMMIT
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user