-C Simplifications\sand\scomment\senhancements\son\sbtree.c.\s(CVS\s6925)
-D 2009-07-23T01:44:00
+C Simplifications\sand\scomment\simprovements\sin\spager.c.\s(CVS\s6926)
+D 2009-07-24T12:35:57
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
F src/os_unix.c cdb2a08b9ce4aa13b3f7b91d4dd60fb48be9f56a
F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405
-F src/pager.c 2149b8271e18aa687456ac4b71ca3b3ad3c26adb
+F src/pager.c cc446ee38f0caf5fab47353f769711e02fda7a0d
F src/pager.h 5bd96ed838e4156e0effa5ffe746bce4c0112c24
F src/parse.y bcd46d43fbd23a22b8c020a3eb1806b794794ed5
F src/pcache.c 1dae135b70a029f81ed66f6e9b5d0db91480d5d0
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 803ec79f3b05fdd680f9ab762685bbd50a087b9b
-R 1af5efb9239298a70b679f6a0b5afcda
+P 5ba880dde8a219543ced6f792c7f9ecdcd8c1cbb
+R b8ba3e500c8750934aa1015f54324e22
U drh
-Z 203e36635efa708168ec055bebd9cda7
+Z bf3ffffd67cf82b5b648dccfa3279f49
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.613 2009/07/22 16:41:15 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.614 2009/07/24 12:35:57 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
*/
if( rc==SQLITE_OK && needSync ){
assert( !MEMDB && pPager->noSync==0 );
- for(ii=0; ii<nPage && needSync; ii++){
+ for(ii=0; ii<nPage; ii++){
PgHdr *pPage = pager_lookup(pPager, pg1+ii);
if( pPage ){
pPage->flags |= PGHDR_NEED_SYNC;
** change-counter, stored as a 4-byte big-endian integer starting at
** byte offset 24 of the pager file.
**
-** If the isDirect flag is zero, then this is done by calling
+** If the isDirectMode flag is zero, then this is done by calling
** sqlite3PagerWrite() on page 1, then modifying the contents of the
** page data. In this case the file will be updated when the current
** transaction is committed.
**
-** The isDirect flag may only be non-zero if the library was compiled
+** The isDirectMode flag may only be non-zero if the library was compiled
** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,
** if isDirect is non-zero, then the database file is updated directly
** by writing an updated version of page 1 using a call to the
** "if( isDirect )" condition.
*/
#ifndef SQLITE_ENABLE_ATOMIC_WRITE
- const int isDirect = 0;
+# define DIRECT_MODE 0
assert( isDirectMode==0 );
UNUSED_PARAMETER(isDirectMode);
#else
- const int isDirect = isDirectMode;
+# define DIRECT_MODE isDirectMode
#endif
assert( pPager->state>=PAGER_RESERVED );
/* If page one was fetched successfully, and this function is not
** operating in direct-mode, make page 1 writable.
*/
- if( rc==SQLITE_OK && !isDirect ){
+ if( rc==SQLITE_OK && !DIRECT_MODE ){
rc = sqlite3PagerWrite(pPgHdr);
}
put32bits(((char*)pPgHdr->pData)+24, change_counter);
/* If running in direct mode, write the contents of page 1 to the file. */
- if( isDirect ){
+ if( DIRECT_MODE ){
const void *zBuf = pPgHdr->pData;
assert( pPager->dbFileSize>0 );
rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
- }
-
- /* If everything worked, set the changeCountDone flag. */
- if( rc==SQLITE_OK ){
+ if( rc==SQLITE_OK ){
+ pPager->changeCountDone = 1;
+ }
+ }else{
pPager->changeCountDone = 1;
}
}
){
int rc = SQLITE_OK; /* Return code */
- if( pPager->errCode ){
- return pPager->errCode;
- }
+ /* If a prior error occurred, this routine should not be called. ROLLBACK
+ ** is the appropriate response to an error, not COMMIT. Guard against
+ ** coding errors by repeating the prior error. */
+ if( NEVER(pPager->errCode) ) return pPager->errCode;
PAGERTRACE(("DATABASE SYNC: File=%s zMaster=%s nSize=%d\n",
pPager->zFilename, zMaster, pPager->dbSize));
- /* If this is an in-memory db, or no pages have been written to, or this
- ** function has already been called, it is a no-op.
- */
if( MEMDB && pPager->dbModified ){
+ /* If this is an in-memory db, or no pages have been written to, or this
+ ** function has already been called, it is mostly a no-op. However, any
+ ** backup in progress needs to be restarted.
+ */
sqlite3BackupRestart(pPager->pBackup);
}else if( pPager->state!=PAGER_SYNCED && pPager->dbModified ){
}
commit_phase_one_exit:
- if( rc==SQLITE_IOERR_BLOCKED ){
- /* pager_incr_changecounter() may attempt to obtain an exclusive
- ** lock to spill the cache and return IOERR_BLOCKED. But since
- ** there is no chance the cache is inconsistent, it is
- ** better to return SQLITE_BUSY.
- **/
- rc = SQLITE_BUSY;
- }
return rc;
}
int sqlite3PagerCommitPhaseTwo(Pager *pPager){
int rc = SQLITE_OK; /* Return code */
- /* Do not proceed if the pager is already in the error state. */
- if( pPager->errCode ){
- return pPager->errCode;
- }
+ /* This routine should not be called if a prior error has occurred.
+ ** But if (due to a coding error elsewhere in the system) it does get
+ ** called, just return the same error code without doing anything. */
+ if( NEVER(pPager->errCode) ) return pPager->errCode;
/* This function should not be called if the pager is not in at least
** PAGER_RESERVED state. And indeed SQLite never does this. But it is
- ** nice to have this defensive block here anyway.
+ ** nice to have this defensive test here anyway.
*/
- if( NEVER(pPager->state<PAGER_RESERVED) ){
- return SQLITE_ERROR;
- }
+ if( NEVER(pPager->state<PAGER_RESERVED) ) return SQLITE_ERROR;
/* An optimization. If the database was not actually modified during
** this transaction, the pager is running in exclusive-mode and is