/ Check-in [e5f17078]
Login

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

Overview
Comment:Tease apart the two phases of pager commit. (CVS 3763)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e5f17078a28b6a47d6943d40c526390c36258392
User & Date: drh 2007-03-30 14:46:01
Context
2007-03-30
14:56
Coverage improvements for where.c. (CVS 3764) check-in: 7e0aa964 user: danielk1977 tags: trunk
14:46
Tease apart the two phases of pager commit. (CVS 3763) check-in: e5f17078 user: drh tags: trunk
14:06
Refactoring the btree and pager routines into distinct two-phase commit routines. We've always done a two-phase commit - this change is just making that more apparent in the code. (CVS 3762) check-in: 66b3ad09 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.307 2007/03/30 14:06:34 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.308 2007/03/30 14:46:01 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   #include "os.h"
    26     26   #include "pager.h"
    27     27   #include <assert.h>
    28     28   #include <string.h>
................................................................................
  3703   3703       }
  3704   3704   #endif
  3705   3705   
  3706   3706       /* Write all dirty pages to the database file */
  3707   3707       pPg = pager_get_all_dirty_pages(pPager);
  3708   3708       rc = pager_write_pagelist(pPg);
  3709   3709       if( rc!=SQLITE_OK ) goto sync_exit;
         3710  +    pPager->pDirty = 0;
  3710   3711   
  3711   3712       /* Sync the database file. */
  3712   3713       if( !pPager->noSync ){
  3713   3714         rc = sqlite3OsSync(pPager->fd, 0);
  3714   3715       }
  3715   3716       IOTRACE(("DBSYNC %p\n", pPager))
  3716   3717   
................................................................................
  3762   3763         assert( !pHist->pStmt );
  3763   3764       }
  3764   3765   #endif
  3765   3766       pPager->pStmt = 0;
  3766   3767       pPager->state = PAGER_SHARED;
  3767   3768       return SQLITE_OK;
  3768   3769     }
  3769         -  if( pPager->dirtyCache==0 ){
  3770         -    /* Exit early (without doing the time-consuming sqlite3OsSync() calls)
  3771         -    ** if there have been no changes to the database file. */
  3772         -    assert( pPager->needSync==0 );
         3770  +  assert( pPager->journalOpen || !pPager->dirtyCache );
         3771  +  assert( pPager->state==PAGER_SYNCED || !pPager->dirtyCache );
  3773   3772       rc = pager_end_transaction(pPager);
  3774         -  }else{
  3775         -    assert( pPager->journalOpen );
  3776         -    rc = sqlite3PagerCommitPhaseOne(pPager, 0, 0);
  3777         -    if( rc==SQLITE_OK ){
  3778         -      rc = pager_end_transaction(pPager);
  3779         -    }
  3780         -  }
  3781   3773     return pager_error(pPager, rc);
  3782   3774   }
  3783   3775   
  3784   3776   /*
  3785   3777   ** Rollback all changes.  The database falls back to PAGER_SHARED mode.
  3786   3778   ** All in-memory cache pages revert to their original data contents.
  3787   3779   ** The journal is deleted.