SQLite

Check-in [7cd3f6cd3a]
Login

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

Overview
Comment:Change the rollback journal so that it invokes sqlite3_log() make a record of a recovery, just as the WAL journal does.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7cd3f6cd3a39ed1c4bbf9e3508824150632c5bd9
User & Date: drh 2013-04-09 18:36:36.048
Context
2013-04-09
20:04
Limit integrity_check output to 10 lines in mptester scripts. (check-in: 67ee0dc0f4 user: drh tags: trunk)
18:36
Change the rollback journal so that it invokes sqlite3_log() make a record of a recovery, just as the WAL journal does. (check-in: 7cd3f6cd3a user: drh tags: trunk)
16:19
Add extra #ifndef statements in os_unix.c and os_win.c to make sure the memory mapped I/O really is disabled when SQLITE_DISABLE_MMAP is set. (check-in: c1e2523c90 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to mptest/mptest.c.
319
320
321
322
323
324
325



326


327
328
329
330
331
332
333
319
320
321
322
323
324
325
326
327
328

329
330
331
332
333
334
335
336
337







+
+
+
-
+
+







/*
** SQL error log callback
*/
static void sqlErrorCallback(void *pArg, int iErrCode, const char *zMsg){
  UNUSED_PARAMETER(pArg);
  if( (iErrCode&0xff)==SQLITE_SCHEMA && g.iTrace<3 ) return;
  if( g.iTimeout==0 && (iErrCode&0xff)==SQLITE_BUSY && g.iTrace<3 ) return;
  if( iErrCode==SQLITE_OK ){
    logMessage("(info) %s", zMsg);
  }else{
  errorMessage("(errcode=%d) %s", iErrCode, zMsg);
    errorMessage("(errcode=%d) %s", iErrCode, zMsg);
  }
}

/*
** Prepare an SQL statement.  Issue a fatal error if unable.
*/
static sqlite3_stmt *prepareSql(const char *zFormat, ...){
  va_list ap;
Changes to src/pager.c.
2654
2655
2656
2657
2658
2659
2660

2661
2662
2663
2664
2665
2666
2667
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668







+







  u32 nRec;                /* Number of Records in the journal */
  u32 u;                   /* Unsigned loop counter */
  Pgno mxPg = 0;           /* Size of the original file in pages */
  int rc;                  /* Result code of a subroutine */
  int res = 1;             /* Value returned by sqlite3OsAccess() */
  char *zMaster = 0;       /* Name of master journal file if any */
  int needPagerReset;      /* True to reset page prior to first page rollback */
  int nPlayback = 0;       /* Total number of pages restored from journal */

  /* Figure out how many records are in the journal.  Abort early if
  ** the journal is empty.
  */
  assert( isOpen(pPager->jfd) );
  rc = sqlite3OsFileSize(pPager->jfd, &szJ);
  if( rc!=SQLITE_OK ){
2754
2755
2756
2757
2758
2759
2760
2761



2762
2763
2764
2765
2766
2767
2768
2755
2756
2757
2758
2759
2760
2761

2762
2763
2764
2765
2766
2767
2768
2769
2770
2771







-
+
+
+







    */
    for(u=0; u<nRec; u++){
      if( needPagerReset ){
        pager_reset(pPager);
        needPagerReset = 0;
      }
      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);
      if( rc!=SQLITE_OK ){
      if( rc==SQLITE_OK ){
        nPlayback++;
      }else{
        if( rc==SQLITE_DONE ){
          pPager->journalOff = szJ;
          break;
        }else if( rc==SQLITE_IOERR_SHORT_READ ){
          /* If the journal has been truncated, simply stop reading and
          ** processing the journal. This might happen if the journal was
          ** not completely written and synced prior to a crash.  In that
2824
2825
2826
2827
2828
2829
2830




2831
2832
2833
2834
2835
2836
2837
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844







+
+
+
+







  if( rc==SQLITE_OK && zMaster[0] && res ){
    /* If there was a master journal and this routine will return success,
    ** see if it is possible to delete the master journal.
    */
    rc = pager_delmaster(pPager, zMaster);
    testcase( rc!=SQLITE_OK );
  }
  if( isHot && nPlayback ){
    sqlite3_log(SQLITE_OK, "Recovered %d pages from %s",
                nPlayback, pPager->zJournal);
  }

  /* The Pager.sectorSize variable may have been updated while rolling
  ** back a journal created by a process with a different sector size
  ** value. Reset it to the correct value for this process.
  */
  setSectorSize(pPager);
  return rc;