Add further test cases. Fix an assert() in pager.c.

FossilOrigin-Name: 8e65c0e3dac400f6a0ec3b7494fba62c14ed6182
This commit is contained in:
dan 2010-06-30 10:36:18 +00:00
parent 3ad5fd2502
commit 6b63ab47d7
6 changed files with 183 additions and 12 deletions

View File

@ -1,5 +1,5 @@
C Do\snot\scall\spager_open_journal()\sfrom\swithin\sPagerBegin()\sif\sthe\sconnection\sis\sin\sexclusive-access\smode.\sIt\swill\sbe\scalled\sfrom\swithin\sPagerWrite()\sjust\sas\sit\sis\sfor\snon-exclusive\smode\sanyway.
D 2010-06-30T04:36:03
C Add\sfurther\stest\scases.\sFix\san\sassert()\sin\spager.c.
D 2010-06-30T10:36:19
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -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 813d09dd66da03ea12cfa21d17eceec1bc3638f4
F src/pager.c 778df1ad25b679e836e480e62767c625448fb6af
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
@ -531,12 +531,13 @@ F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
F test/nan.test f3a0bcc6ca1acaa370efc5a7571e89507fb5927d
F test/notify1.test 8433bc74bd952fb8a6e3f8d7a4c2b28dfd69e310
F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
F test/notify3.test b923ff67728f363378698fb27b5f41a5a1b4d9e0
F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
F test/pager1.test 4d83d4ac53cb4a5d71a2edaa1c08e783871a3012
F test/pager1.test a87a7dffe28d2940fdea2bac3b3354317f358d3f
F test/pager2.test f5c757c271ce642d36a393ecbfb3aef1c240dcef
F test/pagerfault.test 382bc68bfd92342c1d7608b5a2caeb706ca4fb9a
F test/pagerfault.test 03160cec962526ee46f57e8fb984065fe7748b69
F test/pagerfault2.test 1287f123bd5d20452113739ed7755fd254e502f1
F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
@ -828,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 5e19bc360e098ec06a72f4a86254d8e62e93ea57
R 5e5594cd4eb071b5b3230f1e0b49f110
P cdf2c5c2dd2e4404ffb85a680d31307afea266eb
R aeea8d6e6bedd1415172495b05353710
U dan
Z 149f00e8d8a2d6c3e6c5decd2d696d30
Z 2bc1bd3da71e890911d4e52601f27027

View File

@ -1 +1 @@
cdf2c5c2dd2e4404ffb85a680d31307afea266eb
8e65c0e3dac400f6a0ec3b7494fba62c14ed6182

View File

@ -5291,7 +5291,7 @@ int sqlite3PagerCommitPhaseTwo(Pager *pPager){
if( pPager->dbModified==0 && pPager->exclusiveMode
&& pPager->journalMode==PAGER_JOURNALMODE_PERSIST
){
assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );
assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );
return SQLITE_OK;
}

73
test/notify3.test Normal file
View File

@ -0,0 +1,73 @@
# 2010 June 30
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing the sqlite3_unlock_notify() API.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set esc [sqlite3_enable_shared_cache 1]
sqlite3 db test.db
file delete -force test.db2 test.db2-journal test.db2-wal
sqlite3 db2 test.db2
do_test notify3-1.1 {
execsql {
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES('t1 A', 't1 B');
}
} {}
do_test notify3-1.2 {
execsql {
CREATE TABLE t2(a, b);
INSERT INTO t2 VALUES('t2 A', 't2 B');
} db2
} {}
do_test notify3-1.3 {
execsql {
BEGIN EXCLUSIVE;
INSERT INTO t2 VALUES('t2 C', 't2 D');
} db2
} {}
do_test notify3-1.4 {
catchsql { ATTACH 'test.db2' AS aux }
} {0 {}}
do_test notify3-1.5 {
catchsql { SELECT * FROM t2 }
} {1 {database schema is locked: aux}}
do_test notify3-1.6 {
list [sqlite3_errcode db] [sqlite3_extended_errcode db]
} {SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE}
do_test notify3-1.7 {
sqlite3_extended_result_codes db 1
catch { set ::stmt [sqlite3_prepare_v2 db "SELECT * FROM t2" -1 tail] } msg
set msg
} {(262) database schema is locked: aux}
do_test notify3-1.8 {
set ::when 1
db unlock_notify { set ::res $::when }
set ::when 2
execsql { COMMIT } db2
set ::res
} {2}
do_test notify3-1.9 {
catchsql { SELECT * FROM t2 }
} {0 {{t2 A} {t2 B} {t2 C} {t2 D}}}
sqlite3_enable_shared_cache $esc
finish_test

View File

@ -281,6 +281,8 @@ foreach {tn sql tcl} {
testvfs tv -default 1
tv devchar sequential
}
14 { PRAGMA locking_mode = EXCLUSIVE } {
}
} {
do_test pager1-3.$tn.1 {
eval $tcl
@ -1678,5 +1680,83 @@ do_test pager1-19.1 {
}
} {}
#-------------------------------------------------------------------------
# Test a couple of special cases that come up while committing
# transactions:
#
# pager1-20.1.*: Committing an in-memory database transaction when the
# database has not been modified at all.
#
# pager1-20.2.*: As above, but with a normal db in exclusive-locking mode.
#
# pager1-20.3.*: Committing a transaction in WAL mode where the database has
# been modified, but all dirty pages have been flushed to
# disk before the commit.
#
do_test pager1-20.1.1 {
catch {db close}
sqlite3 db :memory:
execsql {
CREATE TABLE one(two, three);
INSERT INTO one VALUES('a', 'b');
}
} {}
do_test pager1-20.1.2 {
execsql {
BEGIN EXCLUSIVE;
COMMIT;
}
} {}
do_test pager1-20.2.1 {
faultsim_delete_and_reopen
execsql {
PRAGMA locking_mode = exclusive;
PRAGMA journal_mode = persist;
CREATE TABLE one(two, three);
INSERT INTO one VALUES('a', 'b');
}
} {exclusive persist}
do_test pager1-20.2.2 {
execsql {
BEGIN EXCLUSIVE;
COMMIT;
}
} {}
do_test pager1-20.3.1 {
faultsim_delete_and_reopen
db func a_string a_string
execsql {
PRAGMA cache_size = 10;
PRAGMA journal_mode = wal;
BEGIN;
CREATE TABLE t1(x);
CREATE TABLE t2(y);
INSERT INTO t1 VALUES(a_string(800));
INSERT INTO t1 SELECT a_string(800) FROM t1; /* 2 */
INSERT INTO t1 SELECT a_string(800) FROM t1; /* 4 */
INSERT INTO t1 SELECT a_string(800) FROM t1; /* 8 */
INSERT INTO t1 SELECT a_string(800) FROM t1; /* 16 */
INSERT INTO t1 SELECT a_string(800) FROM t1; /* 32 */
COMMIT;
}
} {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
execsql COMMIT
} {}
finish_test

View File

@ -614,6 +614,9 @@ do_faultsim_test pagerfault-13 -prep {
faultsim_test_result {0 {}}
}
}
#---------------------------------------------------------------------------
# Test fault injection into a small backup operation.
#
@ -632,13 +635,28 @@ do_test pagerfault-14-pre1 {
}
faultsim_save_and_close
} {}
do_faultsim_test pagerfault-14 -prep {
do_faultsim_test pagerfault-14a -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_faultsim_test pagerfault-14b -prep {
faultsim_restore_and_reopen
sqlite3 db2 ""
db2 eval { 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
@ -667,7 +685,6 @@ do_faultsim_test pagerfault-15 -prep {
faultsim_integrity_check
}
}
do_test pagerfault-16-pre1 {
faultsim_delete_and_reopen