]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Increase test coverage of wal.c provided by permutation "coverage-wal" on this
authordan <dan@noemail.net>
Thu, 27 Dec 2018 16:49:33 +0000 (16:49 +0000)
committerdan <dan@noemail.net>
Thu, 27 Dec 2018 16:49:33 +0000 (16:49 +0000)
branch.

FossilOrigin-Name: 2f7f893a702728745445f6ef5f914c1157058a8fbdfd1a58cfb8906e5566729d

manifest
manifest.uuid
src/wal.c
test/wal.test
test/wal2recover2.test
test/wal2snapshot.test

index 310e343517873bcf7e8afe474fdd57a4ed391c42..80a2f721d2d5a8cc4efe445be0ccbfe3aedd42ae 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improve\stesting\sof\sthe\swal.c\schanges\son\sthis\sbranch.
-D 2018-12-26T20:42:32.396
+C Increase\stest\scoverage\sof\swal.c\sprovided\sby\spermutation\s"coverage-wal"\son\sthis\nbranch.
+D 2018-12-27T16:49:33.954
 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 9b0402f6e126d13dc324588d0e033c274264dae6972a3d4de0fb0813fa91a840
+F src/wal.c 8bfa18a1c5e04a21a8cb142cdb7f8236ad32300a2298565b6fe1cdd15beee3a6
 F src/wal.h d2a69695c84137f76e19a247a342cb02ab0131001b6f58153d94b71195bbd84d
 F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
 F src/where.c 3818e8a736a05d2cb194e64399af707e367fbcc5c251d785804d02eaf121288e
@@ -1601,17 +1601,17 @@ F test/vtabJ.test d7b73675708cf63cfcb9d443bb451fc01a028347275b7311e51f9fdf3ca675
 F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783
 F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65
 F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad
-F test/wal.test cdf0ca6cc0447520d19ef1c83287824ebeb3e82d75af856511ba96841a79fc9b
+F test/wal.test a233cd4733928a5aaef24738727c4094d561ea68089f93cccd1f6e9dec610212
 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/wal2recover2.test d473784bc72ee70438d1aa1cbe449fb322d7e52e8eaa256135fb3182c66b1c78
 F test/wal2rewrite.test 6ca6f631ffcf871240beab5f02608913fd075c6d0d31310b026c8383c65c9f9c
 F test/wal2savepoint.test 2c82bd6a6ee5066c156040d2e9c2415646fcf96116ae7ad127eaf0c0b4a85f22
 F test/wal2simple.test 96206c98bf64ab20ec00a1c0f6c709e258b98b39f2149889361f31966ce5a703
-F test/wal2snapshot.test 95a919e1c73dee0e0212d10931d03cc1116f68a0ff603163e551aaa5ac7025c1
+F test/wal2snapshot.test 7a5f4629a3c43a43c3440b8b2ea9f07de91a46b0b9eea5f08f62b5bf5b6468df
 F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2
 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
 F test/wal5.test 9c11da7aeccd83a46d79a556ad11a18d3cb15aa9
@@ -1804,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 404f9d99d325ddf82fde6d957860d30b2fb67f232c0878a3cf6df9596541f16e
-R 26605d7d9d3118326625f742a3f1a756
+P 63483e22c775183e01924b5cb3d0f3655b63c3cdd06faf26cacd4d0913c0055c
+R 44506fb1f03e87f3f3981d2947902fad
 U dan
-Z b2f5d8c03c1979ab0271df68769d4d7b
+Z 537fbe586afdb7bdeed308e7bd56f47e
index 457fa69d0a6452397a432b540ea2b52f2029f8a1..f8fc8d6c56cb56fcd987b2480ca4007e50a669c1 100644 (file)
@@ -1 +1 @@
-63483e22c775183e01924b5cb3d0f3655b63c3cdd06faf26cacd4d0913c0055c
\ No newline at end of file
+2f7f893a702728745445f6ef5f914c1157058a8fbdfd1a58cfb8906e5566729d
\ No newline at end of file
index 678c6bb95bf4fc92cfa247bc3a2fc3fcc7ad9062..b90ba4df1a904b714a9370b1c10ff58882db4bbb 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -3885,7 +3885,8 @@ static int walRestartLog(Wal *pWal){
 
     if( walidxGetMxFrame(&pWal->hdr, iApp)>=nWalSize ){
       volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
-      if( walidxGetMxFrame(&pWal->hdr, !iApp)==0 || pInfo->nBackfill ){
+      u32 mxFrame = walidxGetMxFrame(&pWal->hdr, !iApp);
+      if( mxFrame==0 || pInfo->nBackfill ){
         rc = wal2RestartOk(pWal, iApp);
         if( rc==SQLITE_OK ){
           int iNew = !iApp;
@@ -4429,7 +4430,9 @@ int sqlite3WalCheckpoint(
   if( rc==SQLITE_OK ){
     int iCkpt = walidxGetFile(&pWal->hdr);
 
-    if( (walPagesize(pWal)!=nBuf) && walidxGetMxFrame(&pWal->hdr, iCkpt) ){
+    if( (walPagesize(pWal)!=nBuf) 
+     && ((pWal->hdr.mxFrame2 & 0x7FFFFFFF) || pWal->hdr.mxFrame)
+    ){
       rc = SQLITE_CORRUPT_BKPT;
     }else{
       rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
index a003b6ad20abd62c443d49512682e26a5bc17622..f545b580a3a69b4100ef502914eb0938451d25ac 100644 (file)
@@ -1174,7 +1174,7 @@ foreach {tn pgsz works} {
   9  32768    1
  10  65536    1
  11 131072    0
- 11   1016    0
+ 12   1016    0
 } {
 
   if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} {
@@ -1184,14 +1184,14 @@ foreach {tn pgsz works} {
   for {set pg 1} {$pg <= 3} {incr pg} {
     forcecopy testX.db test.db
     forcedelete test.db-wal
-  
+
     # Check that the database now exists and consists of three pages. And
     # that there is no associated wal file.
     #
     do_test wal-18.2.$tn.$pg.1 { file exists test.db-wal } 0
     do_test wal-18.2.$tn.$pg.2 { file exists test.db } 1
     do_test wal-18.2.$tn.$pg.3 { file size test.db } [expr 1024*3]
-  
+
     do_test wal-18.2.$tn.$pg.4 {
 
       # Create a wal file that contains a single frame (database page
@@ -1223,16 +1223,16 @@ foreach {tn pgsz works} {
       puts -nonewline $fd $framehdr
       puts -nonewline $fd $framebody
       close $fd
-  
+
       file size test.db-wal
     } [wal_file_size 1 $pgsz]
-  
+
     do_test wal-18.2.$tn.$pg.5 {
       sqlite3 db test.db
       set rc [catch { db one {PRAGMA integrity_check} } msg]
       expr { $rc!=0 || $msg!="ok" }
     } $works
-  
     db close
   }
 }
index 11804c34a3f91178795270d8bf57f296ee1045a0..3665e78b20f6bda35dfd01e7b8bdbda649dfe20b 100644 (file)
@@ -184,7 +184,6 @@ foreach {tn file field} {
     forcecopy test.db-wal2 test.db2-wal
     forcecopy test.db-wal test.db2-wal2
     wal_incr_hdrfield $file $field
-    breakpoint
     sqlite3 db2 test.db2
     execsql {
       SELECT sum(x) FROM t1;
@@ -211,7 +210,6 @@ foreach {tn nCkpt1 nCkpt2 res} [list \
     wal_set_nckpt test.db2-wal  $nCkpt1
     wal_set_follow test.db2-wal test.db2-wal2
 
-    if {$tn==1} breakpoint
 
     sqlite3 db2 test.db2
     execsql {
@@ -222,6 +220,47 @@ foreach {tn nCkpt1 nCkpt2 res} [list \
   db2 close
 }
 
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 1.8.1 {
+  PRAGMA autovacuum = 0;
+  PRAGMA page_size = 4096;
+  CREATE TABLE t1(x);
+  CREATE TABLE t2(x);
+  WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1500 )
+    INSERT INTO t1 SELECT i FROM s;
+  WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1500 )
+    INSERT INTO t2 SELECT i FROM s;
+
+  PRAGMA journal_mode = wal2;
+  PRAGMA journal_size_limit = 10000;
+
+  WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1500 )
+    INSERT INTO t2 SELECT i FROM s;
+} {wal2 10000}
+
+do_test 1.8.2 {
+  list [file size test.db-wal] [file size test.db-wal2]
+} {24752 0}
+
+do_execsql_test 1.8.3 { PRAGMA user_version = 123 }
+do_test 1.8.4 {
+  list [file size test.db-wal] [file size test.db-wal2]
+} {24752 4152}
+
+do_test 1.8.5 {
+  hexio_write test.db-wal2 [expr 56+16] 0400
+  fix_wal_cksums test.db-wal2
+} {}
+
+do_test 1.8.6 {
+  forcecopy test.db test.db2
+  forcecopy test.db-wal test.db2-wal
+  forcecopy test.db-wal2 test.db2-wal2
+  sqlite3 db2 test.db2
+  catchsql { SELECT * FROM sqlite_master } db2
+} {1 {database disk image is malformed}}
+db2 close
 
 finish_test
 
index 9f461db7d6b7e23208c38656d041c84aced85da2..fbc676b3dadaa0a82964eac7f9465076108b0bf9 100644 (file)
@@ -67,7 +67,7 @@ foreach {tn mode} {1 wal 2 wal2} {
       execsql COMMIT
     } {}
   } else {
-    do_test 2.6 {
+    do_test 2.6.1 {
       execsql BEGIN
       set res [
         list [catch { sqlite3_snapshot_open_blob db main $SNAPSHOT } msg] $msg
@@ -75,6 +75,15 @@ foreach {tn mode} {1 wal 2 wal2} {
       execsql COMMIT
       set res
     } {1 SQLITE_ERROR}
+    do_test 2.6.2 {
+      execsql BEGIN
+      execsql {SELECT * FROM sqlite_master}
+      set res [
+        list [catch { sqlite3_snapshot_open_blob db main $SNAPSHOT } msg] $msg
+      ]
+      execsql COMMIT
+      set res
+    } {1 SQLITE_ERROR}
   }
 }