]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improve testing of the wal.c changes on this branch.
authordan <dan@noemail.net>
Wed, 26 Dec 2018 20:42:32 +0000 (20:42 +0000)
committerdan <dan@noemail.net>
Wed, 26 Dec 2018 20:42:32 +0000 (20:42 +0000)
FossilOrigin-Name: 63483e22c775183e01924b5cb3d0f3655b63c3cdd06faf26cacd4d0913c0055c

manifest
manifest.uuid
src/wal.c
test/permutations.test
test/wal2fault.test [new file with mode: 0644]
test/wal2savepoint.test

index 3a78a082589595b746457541156435a3c3551b31..310e343517873bcf7e8afe474fdd57a4ed391c42 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\slatest\strunk\schanges\swith\sthis\sbranch.
-D 2018-12-26T19:10:59.224
+C Improve\stesting\sof\sthe\swal.c\schanges\son\sthis\sbranch.
+D 2018-12-26T20:42:32.396
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in d8b254f8bb81bab43c340d70d17dc3babab40fcc8a348c8255881f780a45fee6
@@ -593,7 +593,7 @@ F src/vdbesort.c 90aad5a92608f2dd771c96749beabdb562c9d881131a860a7a5bccf66dc3be7
 F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392
 F src/vtab.c 70188a745dc4e57d26e942681ff4b2912b7c8249ad5de3f60f0677b4337bcfaa
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c 328101a4c383b0a8564b03aa9c3f79f9b3b30c1959e4a46f49dd0e62a0a61088
+F src/wal.c 9b0402f6e126d13dc324588d0e033c274264dae6972a3d4de0fb0813fa91a840
 F src/wal.h d2a69695c84137f76e19a247a342cb02ab0131001b6f58153d94b71195bbd84d
 F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
 F src/where.c 3818e8a736a05d2cb194e64399af707e367fbcc5c251d785804d02eaf121288e
@@ -1188,7 +1188,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c
 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
 F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
-F test/permutations.test 928386eb05969cc0effc7be7cfe86ea44ee3fee05a1f9ea75387732475a3fadf
+F test/permutations.test 027d8460ba7a2e7b1332388c81fc896f713e1bba57c7157a8278b6bdfd321111
 F test/pg_common.tcl 301ac19c1a52fd55166d26db929b3b89165c634d52b5f8ad76ea8cb06960db30
 F test/pragma.test c267bf02742c823a191960895b3d52933cebd7beee26757d1ed694f213fcd867
 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
@@ -1604,11 +1604,12 @@ F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad
 F test/wal.test cdf0ca6cc0447520d19ef1c83287824ebeb3e82d75af856511ba96841a79fc9b
 F test/wal2.test 155b9efa999bdb38ce1cd729b9a4fcdbffd6b88be27f039bad1d2929d287d918
 F test/wal2big.test 0b4ec526f9ca4bbabc355042c38045ae2e253fb46eb327bb7693d0122bc6968b
+F test/wal2fault.test 2e8e60cacd5bcd451618aeffd05f676894d17202d3e2986e288d36e2c5993249
 F test/wal2lock.test 0ef98d72dc6bcf7711dedd684760488400d9a9a6eec0dc5d3822060437793552
 F test/wal2recover.test ba8f4bc9397c838734619f9e759bd98b00e355347b3cf80a2e677610d231d5d8
 F test/wal2recover2.test 98749381c2e61574e181a2e288295a3bf93d12f57769db50ecea7fc211d9ad5c
 F test/wal2rewrite.test 6ca6f631ffcf871240beab5f02608913fd075c6d0d31310b026c8383c65c9f9c
-F test/wal2savepoint.test 29725383e7eb8b78fed46333d69dc45b4ed321db43ecc81766aadea991874bef
+F test/wal2savepoint.test 2c82bd6a6ee5066c156040d2e9c2415646fcf96116ae7ad127eaf0c0b4a85f22
 F test/wal2simple.test 96206c98bf64ab20ec00a1c0f6c709e258b98b39f2149889361f31966ce5a703
 F test/wal2snapshot.test 95a919e1c73dee0e0212d10931d03cc1116f68a0ff603163e551aaa5ac7025c1
 F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2
@@ -1803,7 +1804,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 118aa7e32a94ad971a955ab60db5bfc5b6241f93734a41ba83ab72ea71bc9aaa 6821c61f1d71be2be7f867e59fd94582a1eaf45a4d1fb88be995807a77cc22ea
-R 9446c2d66d137856eca38f10c8a3c210
+P 404f9d99d325ddf82fde6d957860d30b2fb67f232c0878a3cf6df9596541f16e
+R 26605d7d9d3118326625f742a3f1a756
 U dan
-Z 215adea076b7047172a8d8ead4404cfa
+Z b2f5d8c03c1979ab0271df68769d4d7b
index b3e91ceedcd02f2a2f7dfec06ea509846e7722ff..457fa69d0a6452397a432b540ea2b52f2029f8a1 100644 (file)
@@ -1 +1 @@
-404f9d99d325ddf82fde6d957860d30b2fb67f232c0878a3cf6df9596541f16e
\ No newline at end of file
+63483e22c775183e01924b5cb3d0f3655b63c3cdd06faf26cacd4d0913c0055c
\ No newline at end of file
index 44a4671a4d6d99b6ba7b2f7cc2659c814528a4db..678c6bb95bf4fc92cfa247bc3a2fc3fcc7ad9062 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -576,7 +576,7 @@ struct WalIndexHdr {
 **   void walidxSetFile(WalIndexHdr*, int val);              // set file
 */
 #define walidxGetMxFrame(pHdr, iWal) \
-  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFF) : (pHdr)->mxFrame)
+  ((iWal) ? ((pHdr)->mxFrame2 & 0x7FFFFFFF) : (pHdr)->mxFrame)
 
 static void walidxSetMxFrame(WalIndexHdr *pHdr, int iWal, u32 mxFrame){
   if( iWal ){
@@ -4427,10 +4427,9 @@ int sqlite3WalCheckpoint(
 
   /* Copy data from the log to the database file. */
   if( rc==SQLITE_OK ){
+    int iCkpt = walidxGetFile(&pWal->hdr);
 
-    if( (walPagesize(pWal)!=nBuf) 
-     && (walidxGetMxFrame(&pWal->hdr, 0) || walidxGetMxFrame(&pWal->hdr, 1))
-    ){
+    if( (walPagesize(pWal)!=nBuf) && walidxGetMxFrame(&pWal->hdr, iCkpt) ){
       rc = SQLITE_CORRUPT_BKPT;
     }else{
       rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
@@ -4444,7 +4443,7 @@ int sqlite3WalCheckpoint(
       if( pnCkpt ){
         if( isWalMode2(pWal) ){
           if( (int)(walCkptInfo(pWal)->nBackfill) ){
-            *pnCkpt = walidxGetMxFrame(&pWal->hdr, !walidxGetFile(&pWal->hdr));
+            *pnCkpt = walidxGetMxFrame(&pWal->hdr, iCkpt);
           }else{
             *pnCkpt = 0;
           }
index f75bad6c7be2aec1823c51e8185248813350c80b..5dc203d80cfdc85fe24ede1a8c6caa3c7ec447a8 100644 (file)
@@ -444,6 +444,7 @@ test_suite "coverage-wal" -description {
   snapshot2.test snapshot3.test snapshot4.test
   snapshot_fault.test snapshot.test snapshot_up.test
   walcrash2.test walcrash3.test walcrash4.test walcrash.test
+  wal2fault.test
 } 
 
 test_suite "coverage-pager" -description {
diff --git a/test/wal2fault.test b/test/wal2fault.test
new file mode 100644 (file)
index 0000000..7067e45
--- /dev/null
@@ -0,0 +1,52 @@
+# 2010 May 03
+#
+# 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/malloc_common.tcl
+source $testdir/lock_common.tcl
+
+ifcapable !wal {finish_test ; return }
+set testprefix wal2fault
+
+do_execsql_test 1.0 {
+  CREATE TABLE t1(x,y);
+  PRAGMA journal_mode = wal2;
+  WITH s(i) AS ( SELECT 100 UNION ALL SELECT i-1 FROM s WHERE (i-1)>0 )
+  INSERT INTO t1 SELECT i, randomblob(i) FROM s;
+  WITH s(i) AS ( SELECT 100 UNION ALL SELECT i-1 FROM s WHERE (i-1)>0 )
+  INSERT INTO t1 SELECT i, randomblob(i) FROM s;
+} {wal2}
+
+do_test 1.1 {
+  expr [file size test.db-wal]>10000
+} {1}
+faultsim_save_and_close
+
+do_faultsim_test 1 -prep {
+  faultsim_restore_and_reopen
+  execsql {
+    PRAGMA journal_size_limit = 10000;
+    SELECT count(*) FROM sqlite_master;
+  }
+} -body {
+  execsql {
+    INSERT INTO t1 VALUES(1, 2);
+  }
+} -test {
+  faultsim_test_result {0 {}}
+}
+
+finish_test
index c875af88c4162771e86dc2d676041f188f695679..f46ff9228023ffc4dfb1697a0e1610f5ea1c98f6 100644 (file)
@@ -55,6 +55,19 @@ do_execsql_test 1.3 {
   PRAGMA integrity_check;
 } {210 ok}
 
+do_execsql_test 1.4 {
+  BEGIN;
+    SAVEPOINT abc;
+      WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 100)
+      INSERT INTO t1 SELECT random(), random(), random() FROM s;
+    ROLLBACK TO abc;
+    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 10)
+    INSERT INTO t1 SELECT random(), random(), random() FROM s;
+  COMMIT;
+  SELECT count(*) FROM t1;
+  PRAGMA integrity_check;
+} {220 ok}
+
 
 finish_test