From: dan Date: Thu, 3 Jun 2010 16:58:46 +0000 (+0000) Subject: Add extra tests for removing elements from wal-index hash tables as part of a rollback. X-Git-Tag: version-3.7.2~307 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=db9d981a8da1454ddc6dbdab0951f0edc7a60123;p=thirdparty%2Fsqlite.git Add extra tests for removing elements from wal-index hash tables as part of a rollback. FossilOrigin-Name: af3e598ad9315a4642dd8fa098dfdbd727770aed --- diff --git a/manifest b/manifest index ffb15ffc68..43f46b91d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Delay\sopening\sthe\ssub-journal\suntil\sSQLite\sactually\sneeds\sto\swrite\sdata\sto\sit. -D 2010-06-03T12:35:28 +C Add\sextra\stests\sfor\sremoving\selements\sfrom\swal-index\shash\stables\sas\spart\sof\sa\srollback. +D 2010-06-03T16:58:46 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -763,6 +763,7 @@ F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d F test/wal.test bfec61450b47cdf09f7d2269f9e9967683b8b0fc F test/wal2.test 1dcbbe59ab662bebb859bb1ede83143f8a39814e +F test/wal3.test cac89168c8f8a8679f1fb5234624d5699a84b2f0 F test/walbak.test e7650a26eb4b8abeca9b145b1af1e63026dde432 F test/walcksum.test 4efa8fb88c32bed8288ea4385a9cc113a5c8f0bf F test/walcrash.test f6d5fb2bb108876f04848720a488065d9deef69f @@ -815,7 +816,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P dd10a547f10364058025c48b28d8fd240bf46aff -R 5a3453abb346b5d651cf46a168ba79fc +P c43deb33ae5f191ea2e054181759beeeb9ea71bf +R 6efb1bc5c3a6c45935bda4dcd092139b U dan -Z ad1006f09932fe90a8f3d7feb00d5c69 +Z bc55eed97c9dec0f32cd0a5d524e87aa diff --git a/manifest.uuid b/manifest.uuid index 4bb17eab32..deb63481ae 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c43deb33ae5f191ea2e054181759beeeb9ea71bf \ No newline at end of file +af3e598ad9315a4642dd8fa098dfdbd727770aed \ No newline at end of file diff --git a/test/wal3.test b/test/wal3.test new file mode 100644 index 0000000000..2d2d8b39cb --- /dev/null +++ b/test/wal3.test @@ -0,0 +1,113 @@ +# 2010 April 13 +# +# 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 operation of the library in +# "PRAGMA journal_mode=WAL" mode. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl +source $testdir/wal_common.tcl +source $testdir/malloc_common.tcl +ifcapable !wal {finish_test ; return } + +set a_string_counter 1 +proc a_string {n} { + global a_string_counter + incr a_string_counter + string range [string repeat "${a_string_counter}." $n] 1 $n +} +db func a_string a_string + +#------------------------------------------------------------------------- +# When a rollback or savepoint rollback occurs, the client may remove +# elements from one of the hash tables in the wal-index. This block +# of test cases tests that nothing appears to go wrong when this is +# done. +# +do_test wal3-1.0 { + execsql { + PRAGMA page_size = 1024; + PRAGMA auto_vacuum = off; + PRAGMA synchronous = normal; + PRAGMA journal_mode = WAL; + PRAGMA wal_autocheckpoint = 0; + BEGIN; + CREATE TABLE t1(x); + INSERT INTO t1 VALUES( a_string(800) ); /* 1 */ + 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 */ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 64 */ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 128*/ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 256 */ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 512 */ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 1024 */ + INSERT INTO t1 SELECT a_string(800) FROM t1; /* 2048 */ + INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 2000; /* 4048 */ + COMMIT; + PRAGMA cache_size = 10; + } + wal_frame_count test.db-wal 1024 +} 4086 + +for {set i 1} {$i < 20} {incr i} { + + do_test wal3-1.$i.1 { + set str [a_string 800] + execsql { UPDATE t1 SET x = $str WHERE rowid = $i } + lappend L [wal_frame_count test.db-wal 1024] + execsql { + BEGIN; + INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 100; + ROLLBACK; + PRAGMA integrity_check; + } + } {ok} + + # Check that everything looks OK from the point of view of an + # external connection. + # + sqlite3 db2 test.db + do_test wal3-1.$i.2 { + execsql { SELECT count(*) FROM t1 } db2 + } 4048 + do_test wal3-1.$i.3 { + execsql { SELECT x FROM t1 WHERE rowid = $i } + } $str + do_test wal3-1.$i.4 { + execsql { PRAGMA integrity_check } db2 + } {ok} + db2 close + + # Check that the file-system in its current state can be recovered. + # + file copy -force test.db test2.db + file copy -force test.db-wal test2.db-wal + file delete -force test2.db-journal + sqlite3 db2 test2.db + do_test wal3-1.$i.5 { + execsql { SELECT count(*) FROM t1 } db2 + } 4048 + do_test wal3-1.$i.6 { + execsql { SELECT x FROM t1 WHERE rowid = $i } + } $str + do_test wal3-1.$i.7 { + execsql { PRAGMA integrity_check } db2 + } {ok} + db2 close +} + +finish_test +