Add coverage test cases. Have sqlite3_backup_step() transform SQLITE_IOERR_NOMEM to SQLITE_NOMEM before returning.
FossilOrigin-Name: 5e19bc360e098ec06a72f4a86254d8e62e93ea57
This commit is contained in:
parent
c8ce39723d
commit
ba3cbf3d4b
22
manifest
22
manifest
@ -1,5 +1,5 @@
|
||||
C Add\stests\sto\spager1.test\sand\spagerfault.test.
|
||||
D 2010-06-29T10:30:24
|
||||
C Add\scoverage\stest\scases.\sHave\ssqlite3_backup_step()\stransform\sSQLITE_IOERR_NOMEM\sto\sSQLITE_NOMEM\sbefore\sreturning.
|
||||
D 2010-06-30T04:29:04
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -110,10 +110,10 @@ F src/alter.c a9ff6f14b3935502537e90194b66c7bc79bed317
|
||||
F src/analyze.c 3457a2af126eb78f20ad239c225a2c8ed61b78b6
|
||||
F src/attach.c 47b230972b52580e3b3bd6ee69e55f3a043b615b
|
||||
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||
F src/backup.c 3dc89da1da8b948554d5daedab5fec1097188a2d
|
||||
F src/backup.c 51d83300fe0baee39405c416ceb19a58ed30a8ed
|
||||
F src/bitvec.c 06ad2c36a9c3819c0b9cbffec7b15f58d5d834e0
|
||||
F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff
|
||||
F src/btree.c 9806fb4030d0af907cf5cd7d4b9c8fd939eccfef
|
||||
F src/btree.c ac51d077487df990de502cd0649e486a1a6cc458
|
||||
F src/btree.h dd83041eda10c17daf023257c1fc883b5f71f85a
|
||||
F src/btreeInt.h b0c87f6725b06a0aa194a6d25d54b16ce9d6e291
|
||||
F src/build.c 31830208adbd6f97bef2517531ed70954a306fde
|
||||
@ -156,7 +156,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
|
||||
F src/os_unix.c ec7c7f7ca224ce2ff58736eebf804b48a75f9946
|
||||
F src/os_win.c 48f67798969ba983487fed5691059ade7fff2ef7
|
||||
F src/pager.c 57713740025de859972c81104c27d57ed9c551c6
|
||||
F src/pager.c c7cf3aa7d9bdb4803bc65a35b1f714fe0a77f55e
|
||||
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
|
||||
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
|
||||
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
|
||||
@ -177,7 +177,7 @@ F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
|
||||
F src/status.c 4df6fe7dce2d256130b905847c6c60055882bdbe
|
||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||
F src/tclsqlite.c b898ab058f51ee57e6b54aa8de902526a5376959
|
||||
F src/test1.c 812467c6cb8af8604e912314b7cd68598a024e79
|
||||
F src/test1.c 1ddb761b09342fbf3e81c7027332f2522673a6fc
|
||||
F src/test2.c e3f564ab1e9fd0b47b0c9e23e7054e38bf0836cf
|
||||
F src/test3.c 4c21700c73a890a47fc685c1097bfb661346ac94
|
||||
F src/test4.c ad03bb987ddedce928f4258c1e7fa4109a73497d
|
||||
@ -534,9 +534,9 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
|
||||
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
|
||||
F test/null.test a8b09b8ed87852742343b33441a9240022108993
|
||||
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
|
||||
F test/pager1.test 28709653e83ce9557a983cce251ff02112d5ecca
|
||||
F test/pager1.test 4d83d4ac53cb4a5d71a2edaa1c08e783871a3012
|
||||
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
|
||||
F test/pagerfault.test e7fd4e54fb362ec16ce3474842ed7af390d88de0
|
||||
F test/pagerfault.test 382bc68bfd92342c1d7608b5a2caeb706ca4fb9a
|
||||
F test/pagerfault2.test 1287f123bd5d20452113739ed7755fd254e502f1
|
||||
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
|
||||
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
|
||||
@ -828,7 +828,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 6b7e419ddc241f457dd69878f09f5c51c70aa379
|
||||
R d8452c9c3029633c6ea47d4358dc9dd2
|
||||
P 008513ee6115f8d6f4b4e1428c1c638282b971a3
|
||||
R 4d038e637f507e57a7e7904b3d6eb6a6
|
||||
U dan
|
||||
Z 673ae6c021fa890a23c09b0dc8b30087
|
||||
Z ec59b3b431545b36d61a7ff1dc492de7
|
||||
|
@ -1 +1 @@
|
||||
008513ee6115f8d6f4b4e1428c1c638282b971a3
|
||||
5e19bc360e098ec06a72f4a86254d8e62e93ea57
|
@ -469,6 +469,9 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
|
||||
assert( rc2==SQLITE_OK );
|
||||
}
|
||||
|
||||
if( rc==SQLITE_IOERR_NOMEM ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
p->rc = rc;
|
||||
}
|
||||
if( p->pDestDb ){
|
||||
|
20
src/btree.c
20
src/btree.c
@ -1585,16 +1585,20 @@ static int getAndInitPage(
|
||||
int rc;
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
|
||||
if( pgno<=0 || pgno>btreePagecount(pBt) ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
rc = btreeGetPage(pBt, pgno, ppPage, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = btreeInitPage(*ppPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
releasePage(*ppPage);
|
||||
if( pgno>btreePagecount(pBt) ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
}else{
|
||||
rc = btreeGetPage(pBt, pgno, ppPage, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = btreeInitPage(*ppPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
releasePage(*ppPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testcase( pgno==0 );
|
||||
assert( pgno!=0 || rc==SQLITE_CORRUPT );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -4708,6 +4708,7 @@ static int pager_write(PgHdr *pPg){
|
||||
** which means they have acquired the necessary locks but the rollback
|
||||
** journal might not yet be open.
|
||||
*/
|
||||
assert( pPager->state>PAGER_SHARED );
|
||||
rc = sqlite3PagerBegin(pPager, 0, pPager->subjInMemory);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
|
@ -2626,7 +2626,7 @@ bad_args:
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: test_errstr <err code>
|
||||
** Usage: sqlite3_test_errstr <err code>
|
||||
**
|
||||
** Test that the english language string equivalents for sqlite error codes
|
||||
** are sane. The parameter is an integer representing an sqlite error code.
|
||||
|
@ -1617,8 +1617,66 @@ do_test pager1-18.5 {
|
||||
ALTER TABLE t1 RENAME TO x1;
|
||||
}
|
||||
catchsql { SELECT * FROM x1 }
|
||||
} {}
|
||||
} {1 {database disk image is malformed}}
|
||||
db close
|
||||
|
||||
do_test pager1-18.6 {
|
||||
faultsim_delete_and_reopen
|
||||
db func a_string a_string
|
||||
execsql {
|
||||
PRAGMA page_size = 1024;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(a_string(800));
|
||||
INSERT INTO t1 VALUES(a_string(800));
|
||||
}
|
||||
|
||||
set root [db one "SELECT rootpage FROM sqlite_master"]
|
||||
db close
|
||||
|
||||
hexio_write test.db [expr ($root-1)*1024 + 8] 00000000
|
||||
sqlite3 db test.db
|
||||
catchsql { SELECT length(x) FROM t1 }
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
do_test pager1-19.1 {
|
||||
sqlite3 db ""
|
||||
db func a_string a_string
|
||||
execsql {
|
||||
PRAGMA page_size = 512;
|
||||
PRAGMA auto_vacuum = 1;
|
||||
CREATE TABLE t1(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,
|
||||
ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,
|
||||
ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,
|
||||
da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,
|
||||
ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,
|
||||
fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,
|
||||
ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,
|
||||
ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,
|
||||
ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,
|
||||
ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,
|
||||
ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,
|
||||
la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,
|
||||
ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn
|
||||
);
|
||||
CREATE TABLE t2(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,
|
||||
ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,
|
||||
ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,
|
||||
da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,
|
||||
ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,
|
||||
fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,
|
||||
ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,
|
||||
ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,
|
||||
ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,
|
||||
ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,
|
||||
ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,
|
||||
la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,
|
||||
ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn
|
||||
);
|
||||
INSERT INTO t1(aa) VALUES( a_string(100000) );
|
||||
INSERT INTO t2(aa) VALUES( a_string(100000) );
|
||||
VACUUM;
|
||||
}
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
|
@ -586,6 +586,11 @@ do_faultsim_test pagerfault-12 -prep {
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test fault injection when SQLite opens a database where the size of the
|
||||
# database file is zero bytes but the accompanying journal file is larger
|
||||
# than that. In this scenario SQLite should delete the journal file
|
||||
# without rolling it back, even if it is in all other respects a valid
|
||||
# hot-journal file.
|
||||
#
|
||||
do_test pagerfault-13-pre1 {
|
||||
faultsim_delete_and_reopen
|
||||
@ -609,7 +614,86 @@ do_faultsim_test pagerfault-13 -prep {
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Test fault injection into a small backup operation.
|
||||
#
|
||||
do_test pagerfault-14-pre1 {
|
||||
faultsim_delete_and_reopen
|
||||
db func a_string a_string;
|
||||
execsql {
|
||||
PRAGMA journal_mode = PERSIST;
|
||||
ATTACH 'test.db2' AS two;
|
||||
BEGIN;
|
||||
CREATE TABLE t1(x, y UNIQUE);
|
||||
CREATE TABLE two.t2(x, y UNIQUE);
|
||||
INSERT INTO t1 VALUES(a_string(333), a_string(444));
|
||||
INSERT INTO t2 VALUES(a_string(333), a_string(444));
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
do_faultsim_test pagerfault-14 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
if {[catch {db backup test.db2} msg]} { error [regsub {.*: } $msg {}] }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}} {1 {}} {1 {SQL logic error or missing database}}
|
||||
}
|
||||
|
||||
do_test pagerfault-15-pre1 {
|
||||
faultsim_delete_and_reopen
|
||||
db func a_string a_string;
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(x, y UNIQUE);
|
||||
INSERT INTO t1 VALUES(a_string(11), a_string(22));
|
||||
INSERT INTO t1 VALUES(a_string(11), a_string(22));
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
do_faultsim_test pagerfault-15 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
db func a_string a_string;
|
||||
} -body {
|
||||
db eval { SELECT * FROM t1 LIMIT 1 } {
|
||||
execsql {
|
||||
BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;
|
||||
BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;
|
||||
}
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
do_test pagerfault-16-pre1 {
|
||||
faultsim_delete_and_reopen
|
||||
execsql { CREATE TABLE t1(x, y UNIQUE) }
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
do_faultsim_test pagerfault-16 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
PRAGMA locking_mode = exclusive;
|
||||
PRAGMA journal_mode = wal;
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
PRAGMA journal_mode = delete;
|
||||
INSERT INTO t1 VALUES(4, 5);
|
||||
PRAGMA journal_mode = wal;
|
||||
INSERT INTO t1 VALUES(6, 7);
|
||||
PRAGMA journal_mode = persist;
|
||||
INSERT INTO t1 VALUES(8, 9);
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {exclusive wal delete wal persist}}
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user