/ Check-in [c666fad1]
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:Make setting "PRAGMA auto_vacuum = incremental" persistent if it is executed before the database file is created. (CVS 4113)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c666fad151f25ab8365c497cd0967f4a5a2adb90
User & Date: danielk1977 2007-06-24 10:14:00
Context
2007-06-24
16:11
Fix for #2451. Code comment changes only. (CVS 4114) check-in: bc61dcbf user: danielk1977 tags: trunk
10:14
Make setting "PRAGMA auto_vacuum = incremental" persistent if it is executed before the database file is created. (CVS 4113) check-in: c666fad1 user: danielk1977 tags: trunk
08:00
Add the "(database.)freelist_count" PRAGMA. For querying the size of the database free-list. (CVS 4112) check-in: 1fb4251a user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.389 2007/06/20 15:14:10 drh Exp $
           12  +** $Id: btree.c,v 1.390 2007/06/24 10:14:00 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  1134   1134       nReserve = zDbHeader[20];
  1135   1135       pBt->maxEmbedFrac = zDbHeader[21];
  1136   1136       pBt->minEmbedFrac = zDbHeader[22];
  1137   1137       pBt->minLeafFrac = zDbHeader[23];
  1138   1138       pBt->pageSizeFixed = 1;
  1139   1139   #ifndef SQLITE_OMIT_AUTOVACUUM
  1140   1140       pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);
         1141  +    pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);
  1141   1142   #endif
  1142   1143     }
  1143   1144     pBt->usableSize = pBt->pageSize - nReserve;
  1144   1145     assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */
  1145   1146     sqlite3PagerSetPagesize(pBt->pPager, pBt->pageSize);
  1146   1147   
  1147   1148   #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
................................................................................
  1539   1540     data[22] = pBt->minEmbedFrac;
  1540   1541     data[23] = pBt->minLeafFrac;
  1541   1542     memset(&data[24], 0, 100-24);
  1542   1543     zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );
  1543   1544     pBt->pageSizeFixed = 1;
  1544   1545   #ifndef SQLITE_OMIT_AUTOVACUUM
  1545   1546     assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );
         1547  +  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );
  1546   1548     put4byte(&data[36 + 4*4], pBt->autoVacuum);
         1549  +  put4byte(&data[36 + 7*4], pBt->incrVacuum);
  1547   1550   #endif
  1548   1551     return SQLITE_OK;
  1549   1552   }
  1550   1553   
  1551   1554   /*
  1552   1555   ** Attempt to start a new transaction. A write-transaction
  1553   1556   ** is started if the second argument is nonzero, otherwise a read-

Changes to src/prepare.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains the implementation of the sqlite3_prepare()
    13     13   ** interface, and routines that contribute to loading the database schema
    14     14   ** from disk.
    15     15   **
    16         -** $Id: prepare.c,v 1.50 2007/05/08 20:37:39 drh Exp $
           16  +** $Id: prepare.c,v 1.51 2007/06/24 10:14:00 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "os.h"
    20     20   #include <ctype.h>
    21     21   
    22     22   /*
    23     23   ** Fill the InitData structure with an error message that indicates
................................................................................
   209    209     ** Meta values are as follows:
   210    210     **    meta[0]   Schema cookie.  Changes with each schema change.
   211    211     **    meta[1]   File format of schema layer.
   212    212     **    meta[2]   Size of the page cache.
   213    213     **    meta[3]   Use freelist if 0.  Autovacuum if greater than zero.
   214    214     **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE
   215    215     **    meta[5]   The user cookie. Used by the application.
   216         -  **    meta[6]   
          216  +  **    meta[6]   Incremental-vacuum flag.
   217    217     **    meta[7]
   218    218     **    meta[8]
   219    219     **    meta[9]
   220    220     **
   221    221     ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to
   222    222     ** the possible values of meta[4].
   223    223     */

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.628 2007/06/24 08:00:43 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.629 2007/06/24 10:14:00 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include <math.h>
    52     52   #include "vdbeInt.h"
    53     53   
................................................................................
  2505   2505   **
  2506   2506   ** Read cookie number P2 from database P1 and push it onto the stack.
  2507   2507   ** P2==0 is the schema version.  P2==1 is the database format.
  2508   2508   ** P2==2 is the recommended pager cache size, and so forth.  P1==0 is
  2509   2509   ** the main database file and P1==1 is the database file used to store
  2510   2510   ** temporary tables.
  2511   2511   **
         2512  +** If P1 is negative, then this is a request to read the size of a
         2513  +** databases free-list. P2 must be set to 1 in this case. The actual
         2514  +** database accessed is ((P1+1)*-1). For example, a P1 parameter of -1
         2515  +** corresponds to database 0 ("main"), a P1 of -1 is database 1 ("temp").
         2516  +**
  2512   2517   ** There must be a read-lock on the database (either a transaction
  2513   2518   ** must be started or there must be an open cursor) before
  2514   2519   ** executing this instruction.
  2515   2520   */
  2516   2521   case OP_ReadCookie: {
  2517   2522     int iMeta;
  2518   2523     int iDb = pOp->p1;

Changes to test/incrvacuum.test.

    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the incremental vacuum feature.
    13     13   #
    14     14   # Note: There are also some tests for incremental vacuum and IO 
    15     15   # errors in incrvacuum_ioerr.test.
    16     16   #
    17         -# $Id: incrvacuum.test,v 1.10 2007/05/24 10:18:22 danielk1977 Exp $
           17  +# $Id: incrvacuum.test,v 1.11 2007/06/24 10:14:00 danielk1977 Exp $
    18     18   
    19     19   set testdir [file dirname $argv0]
    20     20   source $testdir/tester.tcl
    21     21   
    22     22   # If this build of the library does not support auto-vacuum, omit this
    23     23   # whole file.
    24     24   ifcapable {!autovacuum || !pragma} {
................................................................................
   549    549   
   550    550   do_test incrvacuum-10.7 {
   551    551     execsql {
   552    552       PRAGMA incremental_vacuum(0);
   553    553     }
   554    554     expr [file size test.db] / 1024
   555    555   } {1}
          556  +
          557  +#----------------------------------------------------------------
          558  +# Test that if we set the auto_vacuum mode to 'incremental', then
          559  +# create a database, thereafter that database defaults to incremental 
          560  +# vacuum mode.
          561  +#
          562  +db close
          563  +file delete -force test.db test.db-journal
          564  +sqlite3 db test.db
          565  +
          566  +do_test incrvacuum-11.1 {
          567  +  execsql {
          568  +    PRAGMA auto_vacuum;
          569  +  }
          570  +} {0}
          571  +do_test incrvacuum-11.2 {
          572  +  execsql {
          573  +    PRAGMA auto_vacuum = incremental;
          574  +  }
          575  +} {}
          576  +do_test incrvacuum-11.3 {
          577  +  execsql {
          578  +    PRAGMA auto_vacuum;
          579  +  }
          580  +} {2}
          581  +do_test incrvacuum-11.4 {
          582  +  file size test.db
          583  +} {0}
          584  +do_test incrvacuum-11.5 {
          585  +  # Create the database file.
          586  +  execsql { CREATE TABLE abc(a, b, c); }
          587  + 
          588  +  # Close and reopen the connection.
          589  +  db close
          590  +  sqlite3 db test.db
          591  +
          592  +  # Test we are still in incremental vacuum mode.
          593  +  execsql { PRAGMA auto_vacuum; }
          594  +} {2}
          595  +do_test incrvacuum-11.6 {
          596  +  execsql {
          597  +    PRAGMA auto_vacuum = 'full';
          598  +    PRAGMA auto_vacuum;
          599  +  }
          600  +} {1}
          601  +do_test incrvacuum-11.7 {
          602  +  # Close and reopen the connection.
          603  +  db close
          604  +  sqlite3 db test.db
          605  +
          606  +  # Test we are still in incremental vacuum mode.
          607  +  execsql { PRAGMA auto_vacuum; }
          608  +} {2}
   556    609   
   557    610   finish_test
   558    611