SQLite

Check-in [5791407b52]
Login

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

Overview
Comment: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.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | default-synchronous
Files: files | file ages | folders
SHA1: 5791407b523abd24e832fc2361b3e9f01ee2f36a
User & Date: drh 2016-03-08 15:14:26.164
Context
2016-03-08
15:30
Make the SQLITE_DEFAULT_SYNCHRONOUS and SQLITE_DEFAULT_WAL_SYNCHRONOUS values zero-based to agree with PRAGMA synchronous. (Closed-Leaf check-in: 592d210436 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: 5791407b52 user: drh tags: default-synchronous)
14:40
Add compile-time options SQLITE_DEFAULT_SYNCHRONOUS and SQLITE_DEFAULT_WAL_SYNCHRONOUS used to specify the default synchronous settings for all database connections. (check-in: 1fefa967aa user: drh tags: default-synchronous)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
2860
2861
2862
2863
2864
2865
2866















2867
2868
2869

2870
2871
2872
2873
2874
2875
2876
    ** file.
    */
    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){
      int isOpen = 0;
      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
      if( rc!=SQLITE_OK ){
        goto page1_init_failed;















      }else if( isOpen==0 ){
        releasePage(pPage1);
        return SQLITE_OK;

      }
      rc = SQLITE_NOTADB;
    }
#endif

    /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
    ** fractions and the leaf payload fraction values must be 64, 32, and 32.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
>







2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
    ** file.
    */
    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){
      int isOpen = 0;
      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);
      if( rc!=SQLITE_OK ){
        goto page1_init_failed;
      }else{
#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS
        sqlite3 *db;
        Db *pDb;
        if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){
          while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }
          if( pDb->bSyncSet==0
           && pDb->safety_level==SQLITE_DEFAULT_SYNCHRONOUS
          ){
            pDb->safety_level = SQLITE_DEFAULT_WAL_SYNCHRONOUS;
            sqlite3PagerSetFlags(pBt->pPager,
               pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));
          }
        }
#endif
        if( isOpen==0 ){
          releasePage(pPage1);
          return SQLITE_OK;
        }
      }
      rc = SQLITE_NOTADB;
    }
#endif

    /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
    ** fractions and the leaf payload fraction values must be 64, 32, and 32.
Changes to test/unixexcl.test.
83
84
85
86
87
88
89

90
91
92
93
94
95
96
do_multiclient_test tn {
  do_test unixexcl-3.$tn.1 {
    code1 { db close; sqlite3 db file:test.db?psow=0 -vfs unix-excl -uri 1 }
    code2 { db2 close; sqlite3 db2 file:test.db?psow=0 -vfs unix-excl -uri 1 }
    sql1 {
      PRAGMA auto_vacuum = 0;
      PRAGMA journal_mode = WAL;

      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
    }
  } {wal}

  if {$tn==1} {
    do_test unixexcl-3.$tn.1.multiproc {







>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
do_multiclient_test tn {
  do_test unixexcl-3.$tn.1 {
    code1 { db close; sqlite3 db file:test.db?psow=0 -vfs unix-excl -uri 1 }
    code2 { db2 close; sqlite3 db2 file:test.db?psow=0 -vfs unix-excl -uri 1 }
    sql1 {
      PRAGMA auto_vacuum = 0;
      PRAGMA journal_mode = WAL;
      PRAGMA synchronous = FULL;
      CREATE TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
    }
  } {wal}

  if {$tn==1} {
    do_test unixexcl-3.$tn.1.multiproc {
Changes to test/wal2.test.
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
foreach {tn sql reslist} {
  1 { }                                 {10 0 4 0 6 0}
  2 { PRAGMA checkpoint_fullfsync = 1 } {10 4 4 2 6 2}
  3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}
} {
  faultsim_delete_and_reopen

  execsql {PRAGMA auto_vacuum = 0}
  execsql $sql
  do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 }   {}
  do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}

  set sqlite_sync_count 0
  set sqlite_fullsync_count 0








|







1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
foreach {tn sql reslist} {
  1 { }                                 {10 0 4 0 6 0}
  2 { PRAGMA checkpoint_fullfsync = 1 } {10 4 4 2 6 2}
  3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}
} {
  faultsim_delete_and_reopen

  execsql {PRAGMA auto_vacuum = 0; PRAGMA synchronous = FULL;}
  execsql $sql
  do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 }   {}
  do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}

  set sqlite_sync_count 0
  set sqlite_fullsync_count 0

Changes to test/zerodamage.test.
108
109
110
111
112
113
114

115
116
117
118
119
120
121
  # Repeat the previous with POWERSAFE_OVERWRITE off.  Verify that the WAL file
  # is padded.
  #
  do_test zerodamage-3.1 {
    db close
    sqlite3 db file:test.db?psow=FALSE -uri 1
    db eval {

       UPDATE t1 SET y=randomblob(50) WHERE x=124;
    }
    file size test.db-wal
  } {16800}
}

finish_test







>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  # Repeat the previous with POWERSAFE_OVERWRITE off.  Verify that the WAL file
  # is padded.
  #
  do_test zerodamage-3.1 {
    db close
    sqlite3 db file:test.db?psow=FALSE -uri 1
    db eval {
       PRAGMA synchronous=FULL;
       UPDATE t1 SET y=randomblob(50) WHERE x=124;
    }
    file size test.db-wal
  } {16800}
}

finish_test