From: dan Date: Tue, 1 Jun 2010 07:51:47 +0000 (+0000) Subject: Fixes to the test cases in wal2.test. X-Git-Tag: version-3.7.2~328^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f3f3b29624f526b62c7362f38dbbf575788608d;p=thirdparty%2Fsqlite.git Fixes to the test cases in wal2.test. FossilOrigin-Name: cd5fbcbce8b55f24c0bf349b179c26e333ff7172 --- diff --git a/manifest b/manifest index 4c44723b0d..d666dcc53c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Comment\sedits\sand\scleanup\sin\swal.c.\s\sNo\sfunctional\scode\schanges. -D 2010-06-01T01:08:09 +C Fixes\sto\sthe\stest\scases\sin\swal2.test. +D 2010-06-01T07:51:48 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -762,11 +762,11 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d F test/wal.test a54d9be9e82eede1653f7998723ead8ce8a1a580 -F test/wal2.test 6c1596e2fa9944eb6ed562f5fadc94d6da0beee6 +F test/wal2.test a7c0265ecea25e95262d6448dc4fbe3fbe94cf0d F test/walbak.test e7650a26eb4b8abeca9b145b1af1e63026dde432 F test/walcksum.test 4efa8fb88c32bed8288ea4385a9cc113a5c8f0bf F test/walcrash.test f6d5fb2bb108876f04848720a488065d9deef69f -F test/walcrash2.test f37c99f729a30c6916849a4b1d3a161f2c4fb000 +F test/walcrash2.test 14585ad1a2c85da2de721caa3b4deeea55213008 F test/walfault.test f71d4c9a13d4e27086aef55f1e0e94734ffa2f6a F test/walhook.test 67e675127f4acb72f061a12667ce6e5460b06b78 F test/walmode.test 6ca9d710cc9f6545b913abcded6d6b0b15641048 @@ -815,7 +815,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P e46a8f2b752f86c4d8942ee125210516026ffdc2 -R 09bc5e191ce3f59e21c41c3724d44527 -U drh -Z 50c2b0464eb7589c438f6f5d9973cb2c +P e8e666ab8273f5db5265f0773b39820f75b6df1a +R 2d4ce189d914f65f52a0b2f34d21a2a0 +U dan +Z 83ba1556aa3dec7d9475b47421ab5c55 diff --git a/manifest.uuid b/manifest.uuid index 5dc4c3e42a..16b6531a90 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e8e666ab8273f5db5265f0773b39820f75b6df1a \ No newline at end of file +cd5fbcbce8b55f24c0bf349b179c26e333ff7172 \ No newline at end of file diff --git a/test/wal2.test b/test/wal2.test index 47fa20e188..82ee8c4c29 100644 --- a/test/wal2.test +++ b/test/wal2.test @@ -371,6 +371,15 @@ tvfs delete # required the client grabs all exclusive locks (just as it would for a # recovery performed as a pre-cursor to a normal database transaction). # +set expected_locks [list] +lappend expected_locks {1 1 lock exclusive} ;# Lock checkpoint +lappend expected_locks {0 1 lock exclusive} ;# Lock writer +lappend expected_locks {2 6 lock exclusive} ;# Lock recovery & all aReadMark[] +lappend expected_locks {2 6 unlock exclusive} ;# Unlock recovery & aReadMark[] +lappend expected_locks {0 1 unlock exclusive} ;# Unlock writer +lappend expected_locks {3 1 lock exclusive} ;# Lock aReadMark[0] +lappend expected_locks {3 1 unlock exclusive} ;# Unlock aReadMark[0] +lappend expected_locks {1 1 unlock exclusive} ;# Unlock checkpoint do_test wal2-5.1 { proc tvfs_cb {method args} { set ::shm_file [lindex $args 0] @@ -392,7 +401,7 @@ do_test wal2-5.1 { set ::locks [list] execsql { PRAGMA wal_checkpoint } set ::locks -} {CHECKPOINT UNLOCK} +} $expected_locks db close tvfs delete @@ -557,6 +566,11 @@ do_test wal2-6.3.7 { } {main exclusive temp closed} db close + +# This test - wal2-6.4.* - uses a single database connection and the +# [testvfs] instrumentation to test that xShmLock() is being called +# as expected when a WAL database is used with locking_mode=exclusive. +# do_test wal2-6.4.1 { file delete -force test.db test.db-wal test.db-journal proc tvfs_cb {method args} { @@ -566,45 +580,114 @@ do_test wal2-6.4.1 { } testvfs tvfs tvfs_cb sqlite3 db test.db -vfs tvfs +} {} - execsql { +set RECOVERY { + {0 1 lock exclusive} {1 7 lock exclusive} + {1 7 unlock exclusive} {0 1 unlock exclusive} +} +set READMARK0_READ { + {3 1 lock shared} {3 1 unlock shared} +} +set READMARK0_WRITE { + {3 1 lock shared} + {0 1 lock exclusive} {3 1 unlock shared} + {4 1 lock exclusive} {4 1 unlock exclusive} {4 1 lock shared} + {0 1 unlock exclusive} {4 1 unlock shared} +} +set READMARK1_SET { + {4 1 lock exclusive} {4 1 unlock exclusive} +} +set READMARK1_READ { + {4 1 lock shared} {4 1 unlock shared} +} + +foreach {tn sql res expected_locks} { + 2 { PRAGMA journal_mode = WAL; - CREATE TABLE t1(x); - INSERT INTO t1 VALUES('Leonard'); - INSERT INTO t1 VALUES('Arthur'); + BEGIN; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES('Leonard'); + INSERT INTO t1 VALUES('Arthur'); + COMMIT; + } {wal} { + $RECOVERY + $READMARK0_READ + $READMARK0_WRITE } - set ::locks [list] - execsql { PRAGMA locking_mode = exclusive } - set ::locks -} {} -do_test wal2-6.4.2 { - execsql { SELECT * FROM t1 } -} {Leonard Arthur} -do_test wal2-6.4.3 { - set ::locks -} {READ} -do_test wal2-6.4.4 { - execsql { + 3 { + # This test should do the READMARK1_SET locking to populate the + # aReadMark[1] slot with the current mxFrame value. Followed by + # READMARK1_READ to read the database. + # + SELECT * FROM t1 + } {Leonard Arthur} { + $READMARK1_SET + $READMARK1_READ + } + + 4 { + # aReadMark[1] is already set to mxFrame. So just READMARK1_READ + # this time, not READMARK1_SET. + # + SELECT * FROM t1 ORDER BY x + } {Arthur Leonard} { + $READMARK1_READ + } + + 5 { + PRAGMA locking_mode = exclusive + } {exclusive} { } + + 6 { INSERT INTO t1 VALUES('Julius Henry'); SELECT * FROM t1; + } {Leonard Arthur {Julius Henry}} { + $READMARK1_READ } -} {Leonard Arthur {Julius Henry}} -do_test wal2-6.4.5 { - set ::locks -} {READ} -do_test wal2-6.4.6 { - execsql { - PRAGMA locking_mode = NORMAL; - DELETE FROM t1; + + 7 { + INSERT INTO t1 VALUES('Karl'); + SELECT * FROM t1; + } {Leonard Arthur {Julius Henry} Karl} { } + + 8 { + PRAGMA locking_mode = normal + } {normal} { } + + 9 { + SELECT * FROM t1 ORDER BY x + } {Arthur {Julius Henry} Karl Leonard} { } + + 10 { + DELETE FROM t1 + } {} { + $READMARK1_READ } - set ::locks -} {READ UNLOCK} -do_test wal2-6.4.7 { + + 11 { + SELECT * FROM t1 + } {} { + $READMARK1_SET + $READMARK1_READ + } +} { + + set L [list] + foreach el [subst $expected_locks] { lappend L $el } + + set S "" + foreach sq [split $sql "\n"] { + set sq [string trim $sq] + if {[string match {#*} $sq]==0} {append S "$sq\n"} + } + set ::locks [list] - execsql { INSERT INTO t1 VALUES('Karl') } - set ::locks -} {READ WRITE READ UNLOCK} + do_test wal2-6.4.$tn.1 { execsql $S } $res + do_test wal2-6.4.$tn.2 { set ::locks } $L +} + db close tvfs delete diff --git a/test/walcrash2.test b/test/walcrash2.test index b8d7e76ab3..417fe144d7 100644 --- a/test/walcrash2.test +++ b/test/walcrash2.test @@ -91,20 +91,8 @@ for {set nEntry 8} {$nEntry < 8192} {incr nEntry 8} { file size test.db-wal } [wal_file_size 16 1024] } -sqlite3 db2 test.db -breakpoint - db2 eval { - PRAGMA cache_size = 15; - BEGIN; - INSERT INTO t1 VALUES(randomblob(900)); -- 1 row, 1 page - INSERT INTO t1 SELECT * FROM t1; -- 2 rows, 3 pages - INSERT INTO t1 SELECT * FROM t1; -- 4 rows, 5 pages - INSERT INTO t1 SELECT * FROM t1; -- 8 rows, 9 pages - INSERT INTO t1 SELECT * FROM t1; -- 16 rows, 17 pages - INSERT INTO t1 SELECT * FROM t1 LIMIT 3; -- 20 rows, 20 pages - } - do_test walcrash2-1.3 { + sqlite3 db2 test.db execsql { SELECT count(*) FROM t1 } db2 } {0} catch { db2 close }