]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem with mixing temp-files and mmap-mode.
authordan <dan@noemail.net>
Sat, 23 Apr 2016 17:24:16 +0000 (17:24 +0000)
committerdan <dan@noemail.net>
Sat, 23 Apr 2016 17:24:16 +0000 (17:24 +0000)
FossilOrigin-Name: c80c5c62b2e2c5e47e0839f8e2d5b6341ca4a249

manifest
manifest.uuid
src/pager.c
test/temptable2.test

index ec3e51504bdf859df9dc3483425c26d9d46b7222..c7f8ab468f7aa174033fd949f6b4c85e8885b5b2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\ssome\sproblems\sto\sdo\swith\stemp-file\sdatabases\sand\srecovering\sfrom\sIO\sand\sSQLITE_FULL\serrors.
-D 2016-04-23T14:55:28.020
+C Fix\sa\sproblem\swith\smixing\stemp-files\sand\smmap-mode.
+D 2016-04-23T17:24:16.091
 F Makefile.in eba680121821b8a60940a81454316f47a341487a
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836
@@ -362,7 +362,7 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
 F src/os_unix.c d0b41a47eb5f0dc00e423a1723aadeab0e78c85f
 F src/os_win.c 1997a873bfc8296a701bd8e2df8c3d5da5afe956
 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca
-F src/pager.c 4981dc6154ce111361a7cd35eaa26aadf8914ea3
+F src/pager.c cbc8996b773c191107b771424b529307ffdf19ba
 F src/pager.h 329bdf078a4e0a3b35084534d58625d21fd03681
 F src/parse.y 10eb2f3fb62341291528c7984498054731f9d31e
 F src/pcache.c b3230ecfc7f797063fbe167f2845da363e8f07f8
@@ -1111,7 +1111,7 @@ F test/tclsqlite.test e1306001a0ca92250b691ea6d3cecaca5b6342aa
 F test/tempdb.test bd92eba8f20e16a9136e434e20b280794de3cdb6
 F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900
 F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
-F test/temptable2.test e62783549be26283e1b3725f0de3309411be6c84
+F test/temptable2.test 31485911fb33e72c7737087ba5a2b35acafba55a
 F test/temptrigger.test 8ec228b0db5d7ebc4ee9b458fc28cb9e7873f5e1
 F test/tester.tcl 7b740ee852c55e1e72b6ebe5044acee7aa4e5553
 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
@@ -1484,7 +1484,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 49aec9718d61c9f12aed96f530128666c3b01c81
-R 98471ae1c4ed8f399ba91e3e119d0ef8
+P 3d61da4a76af8c9c2a293df085f3ed5a7bb447df
+R 85df4f851dc9e804fc35d28f4dbcf65b
 U dan
-Z 4115a15d29a4b7f5f76b2491e48cc4f1
+Z 50e48f2ab5de65ac7aff6f1c82162e94
index 7b1996a745c0ea809528bc4ca0d94b15180ff4d1..865e4fbe13b4a36c86f55903ca90f7729e225fa0 100644 (file)
@@ -1 +1 @@
-3d61da4a76af8c9c2a293df085f3ed5a7bb447df
\ No newline at end of file
+c80c5c62b2e2c5e47e0839f8e2d5b6341ca4a249
\ No newline at end of file
index a749b8a6b3d1bfa98c29187eac27d04e3b275cca..3f2a1318773e7651c518bf127c953fcc800ea80d 100644 (file)
@@ -2034,7 +2034,7 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){
   sqlite3BitvecDestroy(pPager->pInJournal);
   pPager->pInJournal = 0;
   pPager->nRec = 0;
-  if( pagerFlushOnCommit(pPager) ){
+  if( MEMDB || pagerFlushOnCommit(pPager) ){
     sqlite3PcacheCleanAll(pPager->pPCache);
   }else{
     sqlite3PcacheClearWritable(pPager->pPCache);
@@ -5381,7 +5381,7 @@ int sqlite3PagerGet(
       );
 
       if( rc==SQLITE_OK && pData ){
-        if( pPager->eState>PAGER_READER ){
+        if( pPager->eState>PAGER_READER || pPager->tempFile ){
           pPg = sqlite3PagerLookup(pPager, pgno);
         }
         if( pPg==0 ){
@@ -6219,7 +6219,7 @@ int sqlite3PagerCommitPhaseOne(
 
   assert( MEMDB==0 || pPager->tempFile );
   assert( isOpen(pPager->fd) || pPager->tempFile );
-  if( !isOpen(pPager->fd) ){
+  if( 0==pagerFlushOnCommit(pPager) ){
     /* If this is an in-memory db, or no pages have been written to, or this
     ** function has already been called, it is mostly a no-op.  However, any
     ** backup in progress needs to be restarted.  */
index c5e53de63524ffa632776a9a11ae5f075b1625c4..d71c168ebf1964416cb8eb642b313d50a8d16968 100644 (file)
@@ -316,5 +316,34 @@ foreach {tn mode} {
   }
 }
 
+#-------------------------------------------------------------------------
+# When using mmap mode with a temp file, SQLite must search the cache 
+# before using a mapped page even when there is no write transaction
+# open. For a temp file, the on-disk version may not be up to date.
+#
+sqlite3 db ""
+do_execsql_test 10.0 {
+  PRAGMA cache_size = 50;
+  PRAGMA page_size = 1024;
+  CREATE TABLE t1(a, b, PRIMARY KEY(a)) WITHOUT ROWID;
+  CREATE INDEX i1 ON t1(a);
+  CREATE TABLE t2(x, y);
+  INSERT INTO t2 VALUES(1, 2);
+}
+
+do_execsql_test 10.1 {
+  BEGIN;
+    WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )
+      INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;
+  COMMIT;
+  INSERT INTO t2 VALUES(3, 4);
+}
+
+do_execsql_test 10.2 {
+  PRAGMA mmap_size = 512000;
+  SELECT * FROM t2;
+  PRAGMA integrity_check;
+} {512000 1 2 3 4 ok}
+
 finish_test