]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an issue that was causing the new database image to be assembled entirely
authordan <dan@noemail.net>
Wed, 2 Nov 2016 14:50:19 +0000 (14:50 +0000)
committerdan <dan@noemail.net>
Wed, 2 Nov 2016 14:50:19 +0000 (14:50 +0000)
in heap memory when VACUUMing a database, even if it should use a temp file.
This could cause SQLITE_NOMEM errors when vacuuming very large databases on
32-bit systems.

FossilOrigin-Name: 3028845329c9b7acdec2ec8b01d00d782347454c

manifest
manifest.uuid
src/vacuum.c
test/vacuum5.test

index 5b6bd6df8fffa106aa3eb725b200599b55612cb7..3c2785451b23adb0de43d21c90e9a6514aee40f1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\srequirement\smark.\s\sNo\schanges\sto\scode.
-D 2016-11-02T13:18:46.797
+C Fix\san\sissue\sthat\swas\scausing\sthe\snew\sdatabase\simage\sto\sbe\sassembled\sentirely\nin\sheap\smemory\swhen\sVACUUMing\sa\sdatabase,\seven\sif\sit\sshould\suse\sa\stemp\sfile.\nThis\scould\scause\sSQLITE_NOMEM\serrors\swhen\svacuuming\svery\slarge\sdatabases\son\n32-bit\ssystems.
+D 2016-11-02T14:50:19.363
 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f
@@ -453,7 +453,7 @@ F src/trigger.c 3419bb9862983d84d70735fb4c94b21b934cd0c5
 F src/update.c 8179e699dbd45b92934fd02d3d8e3732e8da8802
 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c
 F src/util.c 3e2da6101888d073e79ecc6af5e0a2f70fa1e498
-F src/vacuum.c 913970b9d86dd6c2b8063ef1af421880f1464ec3
+F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16
 F src/vdbe.c 2edc4fa8a825c79a929766f50bc800ea158646d2
 F src/vdbe.h c044be7050ac6bf596eecc6ab159f5dbc020a3b7
 F src/vdbeInt.h d8a56a491b752dbb5f671963b8c861ec72ea875e
@@ -1345,7 +1345,7 @@ F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d
 F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b
 F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d
 F test/vacuum4.test d3f8ecff345f166911568f397d2432c16d2867d9
-F test/vacuum5.test 0b7ac80c64eed657b4ce2dd6535092c0d6afec6c
+F test/vacuum5.test 800b5e881fa3dfdc1be252f2a45f107c75176628
 F test/vacuummem.test 7b42abb3208bd82dd23a7536588396f295a314f2
 F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
 F test/veryquick.test 57ab846bacf7b90cf4e9a672721ea5c5b669b661
@@ -1529,7 +1529,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 9b3a3b41b59a7ce7d3dd82c7402d6fdc6a5ca43c
-R a9c96cf30359222a62867f4daad253b3
-U drh
-Z ccd9456cce5e8a5cfc9ec8a1242d7e32
+P d18f61b78c8fafef742efbc890382537e8584180
+R 341f21774d345780c95f7c12f21ba1af
+U dan
+Z c3255af0dbcff292701e9438f3a3c514
index 220d973bcfed29342f84075d86902d18aa9972cf..c9f54e8b8c3517786f9317c7358fa3af82c3ad58 100644 (file)
@@ -1 +1 @@
-d18f61b78c8fafef742efbc890382537e8584180
\ No newline at end of file
+3028845329c9b7acdec2ec8b01d00d782347454c
\ No newline at end of file
index 295beb6752da5b4aeacac724cc0499a0f0cab497..25b1258510fc5435e172047d60b225043da826c1 100644 (file)
@@ -191,7 +191,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
 
   sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
   sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
-  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF);
+  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);
 
   /* Begin a transaction and take an exclusive lock on the main database
   ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
index 16b15b64a19b4d39122783cd44ff70fdd0d603c6..c44b200964aa18d28c7b231b14e36fcb9cb0b6fb 100644 (file)
@@ -14,6 +14,7 @@
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
+set testprefix vacuum5
 
 # If the VACUUM statement is disabled in the current build, skip all
 # the tests in this file.
@@ -111,4 +112,41 @@ do_catchsql_test vacuum5-2.0 {
   VACUUM olaf;
 } {1 {unknown database olaf}}
 
+#-------------------------------------------------------------------------
+# Test that a temp file is opened as part of VACUUM.
+#
+if {$::TEMP_STORE<3} {
+  db close
+  testvfs tvfs 
+  tvfs filter xOpen
+  tvfs script open_cb
+  forcedelete test.db
+
+  set ::openfiles [list]
+  proc open_cb {method args} {
+    lappend ::openfiles [file tail [lindex $args 0]]
+  }
+  sqlite3 db test.db -vfs tvfs
+
+  do_execsql_test 3.0 {
+    PRAGMA page_size = 1024;
+    PRAGMA cache_size = 50;
+    CREATE TABLE t1(i INTEGER PRIMARY KEY, j UNIQUE);
+    WITH s(i) AS (
+      VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000
+    )
+    INSERT INTO t1 SELECT NULL, randomblob(100) FROM s;
+  }
+
+  do_execsql_test 3.1 { VACUUM }
+
+  db close
+  tvfs delete
+  do_test 3.2 {
+    set ::openfiles
+  } {test.db test.db-journal test.db-journal {} test.db-journal}
+} 
+
+
+
 finish_test