SQLite

Check-in [b21b911f23]
Login

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

Overview
Comment:After a rollback that writes or truncates the database file, sync the database file before invalidating the journal contents. Fix for [015d3820f2].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b21b911f233842357af9ccc14525bbd48a38edb1
User & Date: dan 2010-03-22 17:13:53.000
Original Comment: After a rollback that writes or truncates the database file, sync the database file before invalidating the journal contents.
References
2010-03-26
17:37
After any rollback that modifies the database file, sync the database before deleting the rollback journal. This is a cherry-pick merge of check-ins [b21b911f23] and [f2326dad4e] (check-in: ca0bc2a22e user: drh tags: branch-3.6.23)
2010-03-22
23:55
Sync the database file after a rollback. This is a cherrypick merge of check-in [b21b911f23]. (Leaf check-in: 82dd61fccf user: drh tags: branch-3.6.22)
Context
2010-03-22
17:38
Add an extra test case for crash recovery. (check-in: f2326dad4e user: dan tags: trunk)
17:13
After a rollback that writes or truncates the database file, sync the database file before invalidating the journal contents. Fix for [015d3820f2]. (check-in: b21b911f23 user: dan tags: trunk)
15:47
Disable the "init.test" test script when compiled with SQLITE_THREADSAFE=0. (check-in: ad68fa65bb user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
2013
2014
2015
2016
2017
2018
2019



2020
2021
2022
2023
2024
2025
2026
  */
  pPager->changeCountDone = pPager->tempFile;

  if( rc==SQLITE_OK ){
    zMaster = pPager->pTmpSpace;
    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
    testcase( rc!=SQLITE_OK );



  }
  if( rc==SQLITE_OK ){
    rc = pager_end_transaction(pPager, zMaster[0]!='\0');
    testcase( rc!=SQLITE_OK );
  }
  if( rc==SQLITE_OK && zMaster[0] && res ){
    /* If there was a master journal and this routine will return success,







>
>
>







2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
  */
  pPager->changeCountDone = pPager->tempFile;

  if( rc==SQLITE_OK ){
    zMaster = pPager->pTmpSpace;
    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
    testcase( rc!=SQLITE_OK );
  }
  if( rc==SQLITE_OK && pPager->noSync==0 && pPager->state>=PAGER_EXCLUSIVE ){
    rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
  }
  if( rc==SQLITE_OK ){
    rc = pager_end_transaction(pPager, zMaster[0]!='\0');
    testcase( rc!=SQLITE_OK );
  }
  if( rc==SQLITE_OK && zMaster[0] && res ){
    /* If there was a master journal and this routine will return success,
Changes to test/crash8.test.
335
336
337
338
339
340
341


























342
343
  } {def}

  do_test crash8-4.10 {
    file delete $zMasterJournal
    execsql { SELECT b FROM main.ab WHERE a = 0 }
  } {jkl}
}



























finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
  } {def}

  do_test crash8-4.10 {
    file delete $zMasterJournal
    execsql { SELECT b FROM main.ab WHERE a = 0 }
  } {jkl}
}

catch { db close }
file delete -force test.db test.db-journal
sqlite3 db test.db

do_test crash8-5.1 {
  execsql {
    CREATE TABLE t1(x PRIMARY KEY);
    INSERT INTO t1 VALUES(randomblob(900));
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;
    INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 */
  }
  crashsql -file test.db -delay 1 {
    PRAGMA cache_size = 10;
    BEGIN;
      UPDATE t1 SET x = randomblob(900);
    ROLLBACK;
    INSERT INTO t1 VALUES(randomblob(900));
  }
  execsql { PRAGMA integrity_check }
} {ok}


finish_test