/ Check-in [6d142025]
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:Add the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE sqlite3_dbconfig() option - for disabling SQLite's default checkpoint-on-close behaviour.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6d142025c74f66f2d48155354b556cd5b2682cb2
User & Date: dan 2016-10-31 16:49:18
Context
2016-11-02
02:17
Use NOT NULL partial indexes when the query is constrained by a single LIKE or GLOB. check-in: 9b3a3b41 user: drh tags: trunk
2016-10-31
16:49
Add the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE sqlite3_dbconfig() option - for disabling SQLite's default checkpoint-on-close behaviour. check-in: 6d142025 user: dan tags: trunk
16:16
Add the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE sqlite3_dbconfig() option - for disabling SQLite's default checkpoint-on-close behaviour. Closed-Leaf check-in: 093d2fc2 user: dan tags: no-ckpt-on-close
2016-10-27
14:51
Remove the mutex from test_multiplex.c. check-in: 6374978e user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

   806    806           int op;      /* The opcode */
   807    807           u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */
   808    808         } aFlagOp[] = {
   809    809           { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },
   810    810           { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },
   811    811           { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },
   812    812           { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension  },
          813  +        { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,      SQLITE_NoCkptOnClose  },
   813    814         };
   814    815         unsigned int i;
   815    816         rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
   816    817         for(i=0; i<ArraySize(aFlagOp); i++){
   817    818           if( aFlagOp[i].op==op ){
   818    819             int onoff = va_arg(ap, int);
   819    820             int *pRes = va_arg(ap, int*);

Changes to src/sqlite.h.in.

  1984   1984   ** schema.  ^The sole argument is a pointer to a constant UTF8 string
  1985   1985   ** which will become the new schema name in place of "main".  ^SQLite
  1986   1986   ** does not make a copy of the new main schema name string, so the application
  1987   1987   ** must ensure that the argument passed into this DBCONFIG option is unchanged
  1988   1988   ** until after the database connection closes.
  1989   1989   ** </dd>
  1990   1990   **
         1991  +** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
         1992  +** <dd> Usually, when a database in wal mode is closed or detached from a 
         1993  +** database handle, SQLite checks if this will mean that there are now no 
         1994  +** connections at all to the database. If so, it performs a checkpoint 
         1995  +** operation before closing the connection. This option may be used to
         1996  +** override this behaviour. The first parameter passed to this operation
         1997  +** is an integer - non-zero to disable checkpoints-on-close, or zero (the
         1998  +** default) to enable them. The second parameter is a pointer to an integer
         1999  +** into which is written 0 or 1 to indicate whether checkpoints-on-close
         2000  +** have been disabled - 0 if they are not disabled, 1 if they are.
         2001  +** </dd>
         2002  +**
  1991   2003   ** </dl>
  1992   2004   */
  1993   2005   #define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
  1994   2006   #define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
  1995   2007   #define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
  1996   2008   #define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */
  1997   2009   #define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
  1998   2010   #define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
         2011  +#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */
  1999   2012   
  2000   2013   
  2001   2014   /*
  2002   2015   ** CAPI3REF: Enable Or Disable Extended Result Codes
  2003   2016   ** METHOD: sqlite3
  2004   2017   **
  2005   2018   ** ^The sqlite3_extended_result_codes() routine enables or disables the

Changes to src/sqliteInt.h.

  1431   1431   #define SQLITE_EnableTrigger  0x01000000  /* True to enable triggers */
  1432   1432   #define SQLITE_DeferFKs       0x02000000  /* Defer all FK constraints */
  1433   1433   #define SQLITE_QueryOnly      0x04000000  /* Disable database changes */
  1434   1434   #define SQLITE_VdbeEQP        0x08000000  /* Debug EXPLAIN QUERY PLAN */
  1435   1435   #define SQLITE_Vacuum         0x10000000  /* Currently in a VACUUM */
  1436   1436   #define SQLITE_CellSizeCk     0x20000000  /* Check btree cell sizes on load */
  1437   1437   #define SQLITE_Fts3Tokenizer  0x40000000  /* Enable fts3_tokenizer(2) */
         1438  +#define SQLITE_NoCkptOnClose  0x80000000  /* No checkpoint on close()/DETACH */
  1438   1439   
  1439   1440   
  1440   1441   /*
  1441   1442   ** Bits of the sqlite3.dbOptFlags field that are used by the
  1442   1443   ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
  1443   1444   ** selectively disable various optimizations.
  1444   1445   */

Changes to src/test1.c.

  7217   7217       const char *zName;
  7218   7218       int eVal;
  7219   7219     } aSetting[] = {
  7220   7220       { "FKEY",            SQLITE_DBCONFIG_ENABLE_FKEY },
  7221   7221       { "TRIGGER",         SQLITE_DBCONFIG_ENABLE_TRIGGER },
  7222   7222       { "FTS3_TOKENIZER",  SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },
  7223   7223       { "LOAD_EXTENSION",  SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },
         7224  +    { "NO_CKPT_ON_CLOSE",SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },
  7224   7225     };
  7225   7226     int i;
  7226   7227     int v;
  7227   7228     const char *zSetting;
  7228   7229     sqlite3 *db;
  7229   7230   
  7230   7231     if( objc!=4 ){

Changes to src/wal.c.

  1939   1939       ** ordinary, rollback-mode locking methods, this guarantees that the
  1940   1940       ** connection associated with this log file is the only connection to
  1941   1941       ** the database. In this case checkpoint the database and unlink both
  1942   1942       ** the wal and wal-index files.
  1943   1943       **
  1944   1944       ** The EXCLUSIVE lock is not released before returning.
  1945   1945       */
  1946         -    rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE);
  1947         -    if( rc==SQLITE_OK ){
         1946  +    if( (db->flags & SQLITE_NoCkptOnClose)==0 
         1947  +     && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))
         1948  +    ){
  1948   1949         if( pWal->exclusiveMode==WAL_NORMAL_MODE ){
  1949   1950           pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;
  1950   1951         }
  1951   1952         rc = sqlite3WalCheckpoint(pWal, db, 
  1952   1953             SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0
  1953   1954         );
  1954   1955         if( rc==SQLITE_OK ){

Added test/nockpt.test.

            1  +# 2016 October 31
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this file is testing the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
           13  +# option.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +source $testdir/lock_common.tcl
           19  +source $testdir/malloc_common.tcl
           20  +source $testdir/wal_common.tcl
           21  +ifcapable !wal {finish_test ; return }
           22  +
           23  +set testprefix nockpt
           24  +
           25  +do_execsql_test 1.0 {
           26  +  PRAGMA page_size = 1024;
           27  +  PRAGMA journal_mode = wal;
           28  +  CREATE TABLE c1(x, y, z);
           29  +  INSERT INTO c1 VALUES(1, 2, 3);
           30  +} {wal}
           31  +
           32  +do_test 1.1 { file exists test.db-wal } 1
           33  +do_test 1.2 { file size test.db-wal } [wal_file_size 3 1024]
           34  +do_test 1.3 { db close } {}
           35  +do_test 1.4 { file exists test.db-wal } 0
           36  +
           37  +sqlite3 db test.db
           38  +do_execsql_test 1.5 {
           39  +  INSERT INTO c1 VALUES(4, 5, 6);
           40  +  INSERT INTO c1 VALUES(7, 8, 9);
           41  +}
           42  +do_test 1.6 { file exists test.db-wal } 1
           43  +do_test 1.7 { sqlite3_db_config db NO_CKPT_ON_CLOSE 1 } {1}
           44  +do_test 1.8 { file size test.db-wal } [wal_file_size 2 1024]
           45  +do_test 1.9 { db close } {}
           46  +do_test 1.10 { file exists test.db-wal } 1
           47  +do_test 1.11 { file size test.db-wal } [wal_file_size 2 1024]
           48  +
           49  +sqlite3 db test.db
           50  +do_execsql_test 1.12 {
           51  +  SELECT * FROM c1
           52  +} {1 2 3 4 5 6 7 8 9}
           53  +
           54  +
           55  +finish_test