-C Remove\sthe\sunused\smmapSizeActual\sfield\sfrom\sthe\sWindows\ssqlite3_file\nimplementation.
-D 2018-11-24T16:07:21.425
+C Make\sthe\swinTruncate()\smethod\sof\sthe\swindows\sVFS\sbe\sa\sno-op\sif\sthere\sare\noutstanding\sreferences\sto\sthe\smemory-mapped\spages.\s\sOtherwise,\smemory\smight\nbe\sdeleted\sout\sfrom\sunder\sthose\sreferences\swhen\sthe\sfile\sis\sremapped\sduring\nthe\struncate\soperation.
+D 2018-11-24T17:46:07.403
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in b730006b54c990461d864c5387f2e6f13aadb0236804555fb010ed6865a5f058
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c f6e91b8fd82af7afbfd073c4974ad6cdb8e62d9f65ceddb45167835a0567fdc0
-F src/os_win.c fd94dd9c5738a65f629827df2df458fef8e827031ec99f7e2410bf5811ef979f
+F src/os_win.c 85d9e532d0444ab6c16d7431490c2e279e282aa0917b0e988996b1ae0de5c5a0
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c ff1757f5bb5adb756f22e44c02b235e1d228c6d2c14ae4ea405f2eac7bb0f046
F src/pager.h 1bffa1ba8a742f8b6485ace9fdbceb0924a15c589a0fb86338ce7ed75130b232
F test/incrblob_err.test 89372a28f1d98254f03fed705f9efcd34ef61a674df16d2dbb4726944a2de5e9
F test/incrblobfault.test 74dd8ac108304cea0b4a0df6df63a1567e558758
F test/incrcorrupt.test 6c567fbf870aa9e91866fe52ce6f200cd548939a
-F test/incrvacuum.test b729aab1d4983037da57e66c20dfd7458561a85626dcf824f60175e35f4ce152
+F test/incrvacuum.test d67f6c8330587c6e96e34c19156b67b9f762cd302bdd1d89119fa6edea1ab49b
F test/incrvacuum2.test 7d26cfda66c7e55898d196de54ac4ec7d86a4e3d
F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 81629ba91475938b6ad528e7b1dbef4ad22239782bb2e9c1bb59413aba11da87
-R 4fb4a37d69ae99b1210a8898ab60ca45
+P 0e7aa62227d1d9c3540b54d7caf44a1ce7ccfa706672fc41dbb2be477ab3a667
+Q +8576ccb479fc4b76e950a5c2c5db5c57b59e3c17004b8cca478f0edafd386ec4
+R 9828e9d93ec79c8a535d23c9ae9db165
U drh
-Z 28dc13c8bc7d6c615da3b9b59cc3c652
+Z 1144a278bdd73ccac6950d5ac3539f37
-0e7aa62227d1d9c3540b54d7caf44a1ce7ccfa706672fc41dbb2be477ab3a667
\ No newline at end of file
+ffce4aac18dacbf2a3112ae2ab56c7db20cb164f179683d90a66ef38f4a98f2b
\ No newline at end of file
DWORD lastErrno;
#if SQLITE_MAX_MMAP_SIZE>0
sqlite3_int64 oldMmapSize;
+ if( pFile->nFetchOut>0 ){
+ /* File truncation is a no-op if there are outstanding memory mapped
+ ** pages. This is because truncating the file means temporarily unmapping
+ ** the file, and that might delete memory out from under existing cursors.
+ **
+ ** This can result in incremental vacuum not truncating the file,
+ ** if there is an active read cursor when the incremental vacuum occurs.
+ ** No real harm comes of this - the database file is not corrupted,
+ ** though some folks might complain that the file is bigger than it
+ ** needs to be.
+ **
+ ** The only feasible work-around is to defer the truncation until after
+ ** all references to memory-mapped content are closed. That is doable,
+ ** but involves adding a few branches in the common write code path which
+ ** could slow down normal operations slightly. Hence, we have decided for
+ ** now to simply make trancations a no-op if there are pending reads. We
+ ** can maybe revisit this decision in the future.
+ */
+ return SQLITE_OK;
+ }
#endif
assert( pFile );
}
} {ok}
+#-------------------------------------------------------------------------
+# At one point it was unsafe to truncate a db file on windows while there
+# were outstanding xFetch() references. This test case attempts to hit
+# that case.
+#
+reset_db
+do_execsql_test incrvacuum-16.0 {
+ PRAGMA auto_vacuum = 2;
+ CREATE TABLE t3(a);
+ INSERT INTO t3 VALUES(1), (2), (3), (4);
+
+ CREATE TABLE t2(x);
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+ INSERT INTO t2 VALUES( randomblob(1000) );
+} {}
+
+# Reopen db to ensure the page-cache is empty.
+#
+db close
+sqlite3 db test.db
+
+# Open db in mmap-mode. Open a transaction, delete some data, then run
+# incremental-vacuum. Do not commit the transaction.
+#
+do_execsql_test incrvacuum-16.1 {
+ PRAGMA mmap_size = 1000000;
+ BEGIN;
+ DELETE FROM t2;
+ PRAGMA incremental_vacuum = 1000;
+} {1000000}
+
+# Scan through table t3 (which is all clean pages - so mmap is used). Then,
+# midway through, commit the transaction. This causes the db to be truncated
+# while there are outstanding xFetch pages.
+#
+do_test incrvacuum-16.2 {
+ set res [list]
+ db eval { SELECT a FROM t3 } {
+ if {$a==3} { db eval COMMIT }
+ lappend res $a
+ }
+ set res
+} {1 2 3 4}
+
finish_test