SQLite

Check-in [1ec74591a9]
Login

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

Overview
Comment:Do not delete the journal file in "PRAGMA journal_mode" commands. This fixes [fc62af4523].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1ec74591a93e8b27ad3ac739914a48a91972e82c
User & Date: dan 2010-06-17 10:42:07.000
References
2010-06-17
13:22 Ticket [fc62af4523] Executing "PRAGMA journal_mode" may delete journal file while it is in use. status still Open with 1 other change (artifact: 068d606ebb user: drh)
Context
2010-06-17
16:08
Fix the tkt-fc62af4523.test to work around non-randomness of the randomblob() function when in testing mode. (check-in: 7c3a86b9c7 user: drh tags: trunk)
10:52
Merge trunk updates with experimental branch. Also add tests to journal2.test. (check-in: 9f6ea1de5a user: dan tags: experimental)
10:42
Do not delete the journal file in "PRAGMA journal_mode" commands. This fixes [fc62af4523]. (check-in: 1ec74591a9 user: dan tags: trunk)
10:24
Add test case for [fc62af4523]. (check-in: cccd32c692 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
    */
    if( isOpen(pPager->jfd) && eMode!=PAGER_JOURNALMODE_WAL ){
      sqlite3OsClose(pPager->jfd);
    }

    /* Change the journal mode. */
    pPager->journalMode = (u8)eMode;

    /* When transistioning from TRUNCATE or PERSIST to any other journal
    ** mode (and we are not in locking_mode=EXCLUSIVE) then delete the
    ** journal file.
    */
    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );
    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );
    assert( (PAGER_JOURNALMODE_DELETE & 5)!=1 );
    assert( (PAGER_JOURNALMODE_MEMORY & 5)!=1 );
    assert( (PAGER_JOURNALMODE_OFF & 5)!=1 );
    assert( (PAGER_JOURNALMODE_WAL & 5)!=1 );
    if( (eOld & 5)==1 && (eMode & 5)!=1 && !pPager->exclusiveMode ){
      sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);
    }
  }

  /* Return the new journal mode */
  return (int)pPager->journalMode;
}

/*







<
<
<
<
<
<
<
<
<
<
<
<
<
<







5873
5874
5875
5876
5877
5878
5879














5880
5881
5882
5883
5884
5885
5886
    */
    if( isOpen(pPager->jfd) && eMode!=PAGER_JOURNALMODE_WAL ){
      sqlite3OsClose(pPager->jfd);
    }

    /* Change the journal mode. */
    pPager->journalMode = (u8)eMode;














  }

  /* Return the new journal mode */
  return (int)pPager->journalMode;
}

/*
Changes to test/jrnlmode.test.
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
    do_test jrnlmode-6.5 {
      execsql {
        PRAGMA journal_mode = MEMORY;
        BEGIN;
          INSERT INTO t4 VALUES(3, 4);
      }
      file exists test.db-journal
    } {0}
    do_test jrnlmode-6.7 {
      execsql {
        COMMIT;
        SELECT * FROM t4;
      }
    } {1 2 3 4}
    do_test jrnlmode-6.8 {
      file exists test.db-journal
    } {0}
    do_test jrnlmode-6.9 {
      execsql {
        PRAGMA journal_mode = DELETE;
        BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;
      }
      file exists test.db-journal
    } {0}







|








|







480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
    do_test jrnlmode-6.5 {
      execsql {
        PRAGMA journal_mode = MEMORY;
        BEGIN;
          INSERT INTO t4 VALUES(3, 4);
      }
      file exists test.db-journal
    } {1}
    do_test jrnlmode-6.7 {
      execsql {
        COMMIT;
        SELECT * FROM t4;
      }
    } {1 2 3 4}
    do_test jrnlmode-6.8 {
      file exists test.db-journal
    } {1}
    do_test jrnlmode-6.9 {
      execsql {
        PRAGMA journal_mode = DELETE;
        BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;
      }
      file exists test.db-journal
    } {0}