]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add further tests for the code added on this branch.
authordan <dan@noemail.net>
Sat, 4 Nov 2017 21:06:35 +0000 (21:06 +0000)
committerdan <dan@noemail.net>
Sat, 4 Nov 2017 21:06:35 +0000 (21:06 +0000)
FossilOrigin-Name: a6716fcde38b28b8a03b40f9d16f78a57ec20f60cf391ff553692641cb7f0d3f

manifest
manifest.uuid
src/wal.c
test/walro2.test

index 7e5b9e5a86c1f141898c89bcb1b38a5151cf136e..84f5558cadd3bb19f794e90b5f5a19a33b9ac655 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\scases\swhere\sa\sreadonly_shm\sclient\scannot\stake\sthe\sDMS\slock\son\sthe\s*-shm\nfile,\shave\sit\sparse\sthe\swal\sfile\sand\screate\sa\swal-index\sto\saccess\sit\sin\sheap\nmemory.
-D 2017-11-04T18:10:03.528
+C Add\sfurther\stests\sfor\sthe\scode\sadded\son\sthis\sbranch.
+D 2017-11-04T21:06:35.734
 F Makefile.in 5bae3f2f3d42f2ad52b141562d74872c97ac0fca6c54953c91bb150a0e6427a8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 3a5cb477ec3ce5274663b693164e349db63348667cd45bad78cc13d580b691e2
@@ -543,7 +543,7 @@ F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2
 F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c
 F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c 2b287b5250e89d548c6bbd1d204d0db41046bb3984b9b4a79fc84e22359f1beb
+F src/wal.c 0b3c6b805fc1cf288a7c63b1ac0f78dcc0ad6a54b5b0d72fb0992b16360e7647
 F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a
 F src/walker.c d591e8a9ccf60abb010966b354fcea4aa08eba4d83675c2b281a8764c76cc22f
 F src/where.c b7a075f5fb3d912a891dcc3257f538372bb4a1622dd8ca7d752ad95ce8949ba4
@@ -1527,7 +1527,7 @@ F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03
 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
 F test/walprotocol.test 0b92feb132ccebd855494d917d3f6c2d717ace20
 F test/walro.test 906586c3ae7a991d8c840ceed92400aee21a0a3e4155ce7c4220399777311552
-F test/walro2.test 611ceebd190edeca9bf39e5068cbc864f15294371b4acf9ee837db477840af54
+F test/walro2.test 811ab176ab8571c59c2aac889fdacc7cff8d7a1ceb083796540c2886620a599f
 F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
 F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
 F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e
@@ -1668,7 +1668,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 f569c3517234881f9425075aab65a32ffd0deb8e793f421a241d8cca881da33f
-R 10fc0a1645ce290a2a283e11360fe887
+P 18b268433d739486eac1b04947bd418655e4bc56e8dc63ffa558aa4552a32e30
+R 5345a5078e9be9411c860b392d7c8c77
 U dan
-Z 79ea7f3203670e23f752126d91be88fd
+Z 9992407e85299b3993fc8148a1281ba1
index e8b4f8253219c7b89f491c5af3a6b3868bb996ef..ce4b2816dd1688181177ceba1908c4362a8e2324 100644 (file)
@@ -1 +1 @@
-18b268433d739486eac1b04947bd418655e4bc56e8dc63ffa558aa4552a32e30
\ No newline at end of file
+a6716fcde38b28b8a03b40f9d16f78a57ec20f60cf391ff553692641cb7f0d3f
\ No newline at end of file
index 17e253a8b6cadd5edcc3fabfebd5fb48515cb80e..d8612ec850dc39fe33ae1593787d36640c1bee05 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -2253,6 +2253,10 @@ static int walBeginUnlocked(Wal *pWal, int *pChanged){
   }
   aData = &aFrame[WAL_FRAME_HDRSIZE];
 
+  /* Check to see if a complete transaction has been appended to the
+  ** wal file since the heap-memory wal-index was created. If so, the
+  ** heap-memory wal-index is discarded and WAL_RETRY returned to
+  ** the caller.  */
   aSaveCksum[0] = pWal->hdr.aFrameCksum[0];
   aSaveCksum[1] = pWal->hdr.aFrameCksum[1];
   for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage); 
@@ -2276,7 +2280,9 @@ static int walBeginUnlocked(Wal *pWal, int *pChanged){
     }
     if( !walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame) ) break;
 
-    /* If nTruncate is non-zero, this is a commit record. */
+    /* If nTruncate is non-zero, then a complete transaction has been
+    ** appended to this wal file. Set rc to WAL_RETRY and break out of
+    ** the loop.  */
     if( nTruncate ){
       rc = WAL_RETRY;
       break;
index ee4a341e24d6ac025c4aa00fbe863de2e2afa333..9a6b1a1b5cf855b10e32003df6f727d79df60d30 100644 (file)
@@ -15,7 +15,8 @@
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
 source $testdir/lock_common.tcl
-set ::testprefix walro
+source $testdir/wal_common.tcl
+set ::testprefix walro2
 
 # These tests are only going to work on unix.
 #
@@ -120,10 +121,81 @@ do_multiclient_test tn {
     code3 { db3 close }
     sql1 { COMMIT } 
   } {}
-  breakpoint
   do_test 2.3.3 {
     sql1 { SELECT * FROM t1 }
   } {a b c d e f g h i j}
+
+
+  #-----------------------------------------------------------------------
+  # 3.1.*: That a readonly_shm connection can read a database file if both
+  #        the *-wal and *-shm files are zero bytes in size.
+  #
+  # 3.2.*: That it flushes the cache if, between transactions on a db with a
+  #        zero byte *-wal file, some other connection modifies the db, then
+  #        does "PRAGMA wal_checkpoint=truncate" to truncate the wal file
+  #        back to zero bytes in size.
+  #
+  # 3.3.*: That, if between transactions some other process wraps the wal
+  #        file, the readonly_shm client reruns recovery.
+  #
+  catch { code1 { db close } }
+  catch { code2 { db2 close } }
+  catch { code3 { db3 close } }
+  do_test 3.1.0 {
+    list [file exists test.db-wal] [file exists test.db-shm]
+  } {0 0}
+  do_test 3.1.1 {
+    close [open test.db-wal w]
+    close [open test.db-shm w]
+    code1 {
+      sqlite3 db file:test.db?readonly_shm=1
+    }
+    sql1 { SELECT * FROM t1 }
+  } {a b c d e f g h}
+
+  do_test 3.2.0 {
+    list [file size test.db-wal] [file size test.db-shm]
+  } {0 0}
+  do_test 3.2.1 {
+    code2 { sqlite3 db2 test.db }
+    sql2 { INSERT INTO t1 VALUES(1, 2) ; PRAGMA wal_checkpoint=truncate }
+    code2 { db2 close }
+    sql1 { SELECT * FROM t1 }
+  } {a b c d e f g h 1 2}
+  do_test 3.2.2 {
+    list [file size test.db-wal] [file size test.db-shm]
+  } {0 32768}
+
+  do_test 3.3.0 {
+    code2 { sqlite3 db2 test.db }
+    sql2 { 
+      INSERT INTO t1 VALUES(3, 4);
+      INSERT INTO t1 VALUES(5, 6);
+      INSERT INTO t1 VALUES(7, 8);
+      INSERT INTO t1 VALUES(9, 10);
+    }
+    code2 { db2 close }
+    code1 { db close }
+    list [file size test.db-wal] [file size test.db-shm]
+  } [list [wal_file_size 4 1024] 32768]
+  do_test 3.3.1 {
+    code1 { sqlite3 db file:test.db?readonly_shm=1 }
+    sql1 { SELECT * FROM t1 }
+  } {a b c d e f g h 1 2 3 4 5 6 7 8 9 10}
+  do_test 3.3.2 {
+    code2 { sqlite3 db2 test.db }
+    sql2 { 
+      PRAGMA wal_checkpoint; 
+      DELETE FROM t1;
+      INSERT INTO t1 VALUES('i', 'ii');
+    }
+    code2 { db2 close }
+    list [file size test.db-wal] [file size test.db-shm]
+  } [list [wal_file_size 4 1024] 32768]
+  do_test 3.3.3 {
+    sql1 { SELECT * FROM t1 }
+  } {i ii}
+
 }
 
 finish_test