/ Check-in [3fae483f]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix an issue that was causing the new database image to be assembled entirely 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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.15
Files: files | file ages | folders
SHA1: 3fae483faea3370785ac44ac65dbd03c21b9f6f2
User & Date: drh 2016-11-03 18:36:26
Context
2016-11-03
18:38
Escape non-ASCII character from an ICU extension comment. check-in: ee16fedd user: drh tags: branch-3.15
18:36
Fix an issue that was causing the new database image to be assembled entirely 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. check-in: 3fae483f user: drh tags: branch-3.15
18:35
Make sure left-join markings are transferred to the virtual scalar subexpressions when decomposing a vector comparison in the ON clause of a LEFT JOIN. Fix for ticket [fef4bb4bd9185ec8f]. check-in: aba1e22b user: drh tags: branch-3.15
2016-11-02
14:50
Fix an issue that was causing the new database image to be assembled entirely 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. check-in: 30288453 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vacuum.c.

   187    187       sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
   188    188       if( nKey ) db->nextPagesize = 0;
   189    189     }
   190    190   #endif
   191    191   
   192    192     sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);
   193    193     sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));
   194         -  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF);
          194  +  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);
   195    195   
   196    196     /* Begin a transaction and take an exclusive lock on the main database
   197    197     ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,
   198    198     ** to ensure that we do not try to change the page-size on a WAL database.
   199    199     */
   200    200     rc = execSql(db, pzErrMsg, "BEGIN");
   201    201     if( rc!=SQLITE_OK ) goto end_of_vacuum;

Changes to test/vacuum5.test.

    10     10   #***********************************************************************
    11     11   # 
    12     12   # This file implements a test for VACUUM on attached databases.
    13     13   #
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
           17  +set testprefix vacuum5
    17     18   
    18     19   # If the VACUUM statement is disabled in the current build, skip all
    19     20   # the tests in this file.
    20     21   #
    21     22   ifcapable !vacuum {
    22     23     finish_test
    23     24     return
................................................................................
   106    107   do_execsql_test vacuum5-1.4.2 {
   107    108     PRAGMA temp.page_count;
   108    109   } $sizeTemp
   109    110   
   110    111   do_catchsql_test vacuum5-2.0 {
   111    112     VACUUM olaf;
   112    113   } {1 {unknown database olaf}}
          114  +
          115  +#-------------------------------------------------------------------------
          116  +# Test that a temp file is opened as part of VACUUM.
          117  +#
          118  +if {$::TEMP_STORE<3} {
          119  +  db close
          120  +  testvfs tvfs 
          121  +  tvfs filter xOpen
          122  +  tvfs script open_cb
          123  +  forcedelete test.db
          124  +
          125  +  set ::openfiles [list]
          126  +  proc open_cb {method args} {
          127  +    lappend ::openfiles [file tail [lindex $args 0]]
          128  +  }
          129  +  sqlite3 db test.db -vfs tvfs
          130  +
          131  +  do_execsql_test 3.0 {
          132  +    PRAGMA page_size = 1024;
          133  +    PRAGMA cache_size = 50;
          134  +    CREATE TABLE t1(i INTEGER PRIMARY KEY, j UNIQUE);
          135  +    WITH s(i) AS (
          136  +      VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000
          137  +    )
          138  +    INSERT INTO t1 SELECT NULL, randomblob(100) FROM s;
          139  +  }
          140  +
          141  +  do_execsql_test 3.1 { VACUUM }
          142  +
          143  +  db close
          144  +  tvfs delete
          145  +  do_test 3.2 {
          146  +    set ::openfiles
          147  +  } {test.db test.db-journal test.db-journal {} test.db-journal}
          148  +} 
          149  +
          150  +
   113    151   
   114    152   finish_test