SQLite

Check-in [d1fcccecdc]
Login

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

Overview
Comment:Do not allow journal_mode=WAL if the underlying VFS does not support xShmOpen.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: d1fcccecdc8e9ac5d0d022914e51c545f4e1b04f
User & Date: drh 2010-05-01 00:59:38.000
Context
2010-05-01
08:30
Add test case demonstrating deadlock during recovery of very large log files. No fix yet. (check-in: 63ea318eb1 user: dan tags: wal)
00:59
Do not allow journal_mode=WAL if the underlying VFS does not support xShmOpen. (check-in: d1fcccecdc user: drh tags: wal)
2010-04-30
22:28
Merge in changes from the trunk. (check-in: 76bf0eee1f user: drh tags: wal)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbe.c.
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218



5219

5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232


5233
5234



5235


5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
** modes (delete, truncate, persist, off and memory), this is a simple
** operation. No IO is required.
**
** If changing into or out of WAL mode the procedure is more complicated.
**
** Write a string containing the final journal-mode to register P2.
*/
case OP_JournalMode: {
  Btree *pBt;                     /* Btree to change journal mode of */
  Pager *pPager;                  /* Pager associated with pBt */
  int eNew = pOp->p3;             /* New journal mode */





  assert( eNew==PAGER_JOURNALMODE_DELETE 
       || eNew==PAGER_JOURNALMODE_TRUNCATE 
       || eNew==PAGER_JOURNALMODE_PERSIST 
       || eNew==PAGER_JOURNALMODE_OFF
       || eNew==PAGER_JOURNALMODE_MEMORY
       || eNew==PAGER_JOURNALMODE_WAL
       || eNew==PAGER_JOURNALMODE_QUERY
  );
  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( (p->btreeMask & (1<<pOp->p1))!=0 );

  pBt = db->aDb[pOp->p1].pBt;
  pPager = sqlite3BtreePager(pBt);



  if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(pBt)) 



   && eNew==PAGER_JOURNALMODE_WAL 


  ){
    eNew = PAGER_JOURNALMODE_QUERY;
  }

  if( eNew!=PAGER_JOURNALMODE_QUERY ){
    int eOld = sqlite3PagerJournalMode(pPager, PAGER_JOURNALMODE_QUERY);
    if( (eNew!=eOld)
     && (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)
    ){
      if( !db->autoCommit || db->activeVdbeCnt>1 ){
        rc = SQLITE_ERROR;
        sqlite3SetString(&p->zErrMsg, db, 
            "cannot change %s wal mode from within a transaction",







|


|
>
>
>

>













>
>

<
>
>
>
|
>
>





|







5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239

5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
** modes (delete, truncate, persist, off and memory), this is a simple
** operation. No IO is required.
**
** If changing into or out of WAL mode the procedure is more complicated.
**
** Write a string containing the final journal-mode to register P2.
*/
case OP_JournalMode: {    /* out2-prerelease */
  Btree *pBt;                     /* Btree to change journal mode of */
  Pager *pPager;                  /* Pager associated with pBt */
  int eNew;                       /* New journal mode */
  int eOld;                       /* The old journal mode */
  const sqlite3_vfs *pVfs;        /* The VFS of pPager */
  const char *zFilename;          /* Name of database file for pPager */

  eNew = pOp->p3;
  assert( eNew==PAGER_JOURNALMODE_DELETE 
       || eNew==PAGER_JOURNALMODE_TRUNCATE 
       || eNew==PAGER_JOURNALMODE_PERSIST 
       || eNew==PAGER_JOURNALMODE_OFF
       || eNew==PAGER_JOURNALMODE_MEMORY
       || eNew==PAGER_JOURNALMODE_WAL
       || eNew==PAGER_JOURNALMODE_QUERY
  );
  assert( pOp->p1>=0 && pOp->p1<db->nDb );
  assert( (p->btreeMask & (1<<pOp->p1))!=0 );

  pBt = db->aDb[pOp->p1].pBt;
  pPager = sqlite3BtreePager(pBt);
  zFilename = sqlite3PagerFilename(pPager);
  pVfs = sqlite3PagerVfs(pPager);


  /* Do not allow a transition to journal_mode=WAL for a database
  ** in temporary storage or if the VFS does not support xShmOpen.
  */
  if( eNew==PAGER_JOURNALMODE_WAL
   && (zFilename[0]==0                               /* Temp file */
         || pVfs->iVersion<2 || pVfs->xShmOpen==0)   /* No xShmOpen support */
  ){
    eNew = PAGER_JOURNALMODE_QUERY;
  }

  if( eNew!=PAGER_JOURNALMODE_QUERY ){
    eOld = sqlite3PagerJournalMode(pPager, PAGER_JOURNALMODE_QUERY);
    if( (eNew!=eOld)
     && (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)
    ){
      if( !db->autoCommit || db->activeVdbeCnt>1 ){
        rc = SQLITE_ERROR;
        sqlite3SetString(&p->zErrMsg, db, 
            "cannot change %s wal mode from within a transaction",
Changes to test/walmode.test.
149
150
151
152
153
154
155

156
157
158
159
160
161
162
#   walmode-5.2.*: Try to set journal_mode=WAL on [sqlite3 db ""] database.
#   walmode-5.3.*: Try to set temp.journal_mode=WAL.
#
do_test walmode-5.1.1 {
  sqlite3 db :memory:
  execsql { PRAGMA main.journal_mode }
} {memory}

do_test walmode-5.1.2 {
  execsql { PRAGMA main.journal_mode = wal }
} {memory}
do_test walmode-5.1.3 {
  execsql {
    BEGIN;
      CREATE TABLE t1(a, b);







>







149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#   walmode-5.2.*: Try to set journal_mode=WAL on [sqlite3 db ""] database.
#   walmode-5.3.*: Try to set temp.journal_mode=WAL.
#
do_test walmode-5.1.1 {
  sqlite3 db :memory:
  execsql { PRAGMA main.journal_mode }
} {memory}
breakpoint
do_test walmode-5.1.2 {
  execsql { PRAGMA main.journal_mode = wal }
} {memory}
do_test walmode-5.1.3 {
  execsql {
    BEGIN;
      CREATE TABLE t1(a, b);
201
202
203
204
205
206
207





208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
  execsql { 
    INSERT INTO t1 VALUES(3, 4);
    SELECT * FROM t1;
    PRAGMA main.journal_mode;
  }
} {1 2 3 4 delete}






do_test walmode-5.3.1 {
  sqlite3 db test.db
  execsql { PRAGMA temp.journal_mode }
} {delete}
do_test walmode-5.3.2 {
  execsql { PRAGMA temp.journal_mode = wal }
} {delete}
do_test walmode-5.3.3 {
  execsql {
    BEGIN;
      CREATE TEMP TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
    COMMIT;
    SELECT * FROM t1;
    PRAGMA temp.journal_mode;
  }
} {1 2 delete}
do_test walmode-5.3.4 {
  execsql { PRAGMA temp.journal_mode = wal }
} {delete}
do_test walmode-5.3.5 {
  execsql { 
    INSERT INTO t1 VALUES(3, 4);
    SELECT * FROM t1;
    PRAGMA temp.journal_mode;
  }
} {1 2 3 4 delete}

finish_test








>
>
>
>
>



|


|









|


|






|


<
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242

  execsql { 
    INSERT INTO t1 VALUES(3, 4);
    SELECT * FROM t1;
    PRAGMA main.journal_mode;
  }
} {1 2 3 4 delete}

if {$TEMP_STORE>=2} {
  set tempJrnlMode memory
} else {
  set tempJrnlMode
}
do_test walmode-5.3.1 {
  sqlite3 db test.db
  execsql { PRAGMA temp.journal_mode }
} $tempJrnlMode
do_test walmode-5.3.2 {
  execsql { PRAGMA temp.journal_mode = wal }
} $tempJrnlMode
do_test walmode-5.3.3 {
  execsql {
    BEGIN;
      CREATE TEMP TABLE t1(a, b);
      INSERT INTO t1 VALUES(1, 2);
    COMMIT;
    SELECT * FROM t1;
    PRAGMA temp.journal_mode;
  }
} [list 1 2 $tempJrnlMode]
do_test walmode-5.3.4 {
  execsql { PRAGMA temp.journal_mode = wal }
} $tempJrnlMode
do_test walmode-5.3.5 {
  execsql { 
    INSERT INTO t1 VALUES(3, 4);
    SELECT * FROM t1;
    PRAGMA temp.journal_mode;
  }
} [list 1 2 3 4 $tempJrnlMode]

finish_test