SQLite

Check-in [e5f17078a2]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e5f17078a28b6a47d6943d40c526390c36258392
User & Date: drh 2007-03-30 14:46:01.000
Context
2007-03-30
14:56
Coverage improvements for where.c. (CVS 3764) (check-in: 7e0aa96412 user: danielk1977 tags: trunk)
14:46
Tease apart the two phases of pager commit. (CVS 3763) (check-in: e5f17078a2 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: 66b3ad09ea user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.307 2007/03/30 14:06:34 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include "os.h"
#include "pager.h"
#include <assert.h>
#include <string.h>







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.308 2007/03/30 14:46:01 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include "os.h"
#include "pager.h"
#include <assert.h>
#include <string.h>
3703
3704
3705
3706
3707
3708
3709

3710
3711
3712
3713
3714
3715
3716
    }
#endif

    /* Write all dirty pages to the database file */
    pPg = pager_get_all_dirty_pages(pPager);
    rc = pager_write_pagelist(pPg);
    if( rc!=SQLITE_OK ) goto sync_exit;


    /* Sync the database file. */
    if( !pPager->noSync ){
      rc = sqlite3OsSync(pPager->fd, 0);
    }
    IOTRACE(("DBSYNC %p\n", pPager))








>







3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
    }
#endif

    /* Write all dirty pages to the database file */
    pPg = pager_get_all_dirty_pages(pPager);
    rc = pager_write_pagelist(pPg);
    if( rc!=SQLITE_OK ) goto sync_exit;
    pPager->pDirty = 0;

    /* Sync the database file. */
    if( !pPager->noSync ){
      rc = sqlite3OsSync(pPager->fd, 0);
    }
    IOTRACE(("DBSYNC %p\n", pPager))

3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
      assert( !pHist->pStmt );
    }
#endif
    pPager->pStmt = 0;
    pPager->state = PAGER_SHARED;
    return SQLITE_OK;
  }
  if( pPager->dirtyCache==0 ){
    /* Exit early (without doing the time-consuming sqlite3OsSync() calls)
    ** if there have been no changes to the database file. */
    assert( pPager->needSync==0 );
    rc = pager_end_transaction(pPager);
  }else{
    assert( pPager->journalOpen );
    rc = sqlite3PagerCommitPhaseOne(pPager, 0, 0);
    if( rc==SQLITE_OK ){
      rc = pager_end_transaction(pPager);
    }
  }
  return pager_error(pPager, rc);
}

/*
** Rollback all changes.  The database falls back to PAGER_SHARED mode.
** All in-memory cache pages revert to their original data contents.
** The journal is deleted.







<
<
<
|
<
<
|
<
<
|
<
<







3763
3764
3765
3766
3767
3768
3769



3770


3771


3772


3773
3774
3775
3776
3777
3778
3779
      assert( !pHist->pStmt );
    }
#endif
    pPager->pStmt = 0;
    pPager->state = PAGER_SHARED;
    return SQLITE_OK;
  }



  assert( pPager->journalOpen || !pPager->dirtyCache );


  assert( pPager->state==PAGER_SYNCED || !pPager->dirtyCache );


  rc = pager_end_transaction(pPager);


  return pager_error(pPager, rc);
}

/*
** Rollback all changes.  The database falls back to PAGER_SHARED mode.
** All in-memory cache pages revert to their original data contents.
** The journal is deleted.