/ Check-in [592d2104]
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 the SQLITE_DEFAULT_SYNCHRONOUS and SQLITE_DEFAULT_WAL_SYNCHRONOUS values zero-based to agree with PRAGMA synchronous.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | default-synchronous
Files: files | file ages | folders
SHA1: 592d2104361500e5002783ba329a2609389c57b9
User & Date: drh 2016-03-08 15:30:01
Context
2016-03-08
15:47
Add the SQLITE_DEFAULT_SYNCHRONOUS and SQLITE_DEFAULT_WAL_SYNCHRONOUS compile-time options. Automatically switch to the WAL_SYNCHRONOUS setting when first opening a WAL-mode database if the synchronous setting has not been previously set by the application. check-in: 5a847a67 user: drh tags: trunk
15:30
Make the SQLITE_DEFAULT_SYNCHRONOUS and SQLITE_DEFAULT_WAL_SYNCHRONOUS values zero-based to agree with PRAGMA synchronous. Closed-Leaf check-in: 592d2104 user: drh tags: default-synchronous
15:14
If SQLITE_DEFAULT_WAL_SYNCHRONOUS is not the same value as SQLITE_DEFAULT_SYNCHRONOUS and the application has not run "PRAGMA synchronous", then set synchronous to the SQLITE_DEFAULT_WAL_SYNCHRONOUS setting when entering WAL mode for the first time. check-in: 5791407b user: drh tags: default-synchronous
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   157    157                                sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
   158    158   #ifndef SQLITE_OMIT_PAGER_PRAGMAS
   159    159       sqlite3BtreeSetPagerFlags(aNew->pBt,
   160    160                         PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
   161    161   #endif
   162    162       sqlite3BtreeLeave(aNew->pBt);
   163    163     }
   164         -  aNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS;
          164  +  aNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
   165    165     aNew->zName = sqlite3DbStrDup(db, zName);
   166    166     if( rc==SQLITE_OK && aNew->zName==0 ){
   167    167       rc = SQLITE_NOMEM_BKPT;
   168    168     }
   169    169   
   170    170   
   171    171   #ifdef SQLITE_HAS_CODEC

Changes to src/btree.c.

  2867   2867         }else{
  2868   2868   #if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
  2869   2869           sqlite3 *db;
  2870   2870           Db *pDb;
  2871   2871           if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
  2872   2872             while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
  2873   2873             if( pDb->bSyncSet==0
  2874         -           && pDb->safety_level==SQLITE_DEFAULT_SYNCHRONOUS
         2874  +           && pDb->safety_level==SQLITE_DEFAULT_SYNCHRONOUS+1
  2875   2875             ){
  2876         -            pDb->safety_level = SQLITE_DEFAULT_WAL_SYNCHRONOUS;
         2876  +            pDb->safety_level = SQLITE_DEFAULT_WAL_SYNCHRONOUS+1;
  2877   2877               sqlite3PagerSetFlags(pBt->pPager,
  2878   2878                  pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
  2879   2879             }
  2880   2880           }
  2881   2881   #endif
  2882   2882           if( isOpen==0 ){
  2883   2883             releasePage(pPage1);

Changes to src/main.c.

  2874   2874     sqlite3BtreeLeave(db->aDb[0].pBt);
  2875   2875     db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);
  2876   2876   
  2877   2877     /* The default safety_level for the main database is FULL; for the temp
  2878   2878     ** database it is OFF. This matches the pager layer defaults.  
  2879   2879     */
  2880   2880     db->aDb[0].zName = "main";
  2881         -  db->aDb[0].safety_level = SQLITE_DEFAULT_SYNCHRONOUS;
         2881  +  db->aDb[0].safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
  2882   2882     db->aDb[1].zName = "temp";
  2883   2883     db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF;
  2884   2884   
  2885   2885     db->magic = SQLITE_MAGIC_OPEN;
  2886   2886     if( db->mallocFailed ){
  2887   2887       goto opendb_out;
  2888   2888     }

Changes to src/sqliteInt.h.

  1002   1002   #include "vdbe.h"
  1003   1003   #include "pager.h"
  1004   1004   #include "pcache.h"
  1005   1005   #include "os.h"
  1006   1006   #include "mutex.h"
  1007   1007   
  1008   1008   /*
  1009         -** Default synchronous levels
         1009  +** Default synchronous levels.
         1010  +**
         1011  +** Note that (for historcal reasons) the PAGER_SYNCHRONOUS_* macros differ
         1012  +** from the SQLITE_DEFAULT_SYNCHRONOUS value by 1.
         1013  +**
         1014  +**           PAGER_SYNCHRONOUS       DEFAULT_SYNCHRONOUS
         1015  +**   OFF           1                         0
         1016  +**   NORMAL        2                         1
         1017  +**   FULL          3                         2
         1018  +**   EXTRA         4                         3
         1019  +**
         1020  +** The "PRAGMA synchronous" statement also uses the zero-based numbers.
         1021  +** In other words, the zero-based numbers are used for all external interfaces
         1022  +** and the one-based values are used internally.
  1010   1023   */
  1011   1024   #ifndef SQLITE_DEFAULT_SYNCHRONOUS
  1012         -# define SQLITE_DEFAULT_SYNCHRONOUS PAGER_SYNCHRONOUS_FULL
         1025  +# define SQLITE_DEFAULT_SYNCHRONOUS (PAGER_SYNCHRONOUS_FULL-1)
  1013   1026   #endif
  1014   1027   #ifndef SQLITE_DEFAULT_WAL_SYNCHRONOUS
  1015   1028   # define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS
  1016   1029   #endif
  1017   1030   
  1018   1031   /*
  1019   1032   ** Each database file to be accessed by the system is an instance