-C Simplifications\sand\scomment\simprovements\sin\spager.c.\s(CVS\s6926)
-D 2009-07-24T12:35:57
+C Simplifications\sto\spager.c\sin\ssupport\sof\sstructural\scoverage\stesting.\s(CVS\s6927)
+D 2009-07-24T16:32:01
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 cc446ee38f0caf5fab47353f769711e02fda7a0d
+F src/pager.c 80910e68f6bde91dc96a3dcb5d8e5edf3505fa0d
F src/pager.h 5bd96ed838e4156e0effa5ffe746bce4c0112c24
F src/parse.y bcd46d43fbd23a22b8c020a3eb1806b794794ed5
F src/pcache.c 1dae135b70a029f81ed66f6e9b5d0db91480d5d0
F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
-F test/pager.test d04982df84334a9ed272ed2943b61985be5377ee
+F test/pager.test 2d0abb66c8967ffac4558c0530b31c28706b5e64
F test/pager2.test d4b7f6b70ff018b9995e622a32526b275f515042
F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 5ba880dde8a219543ced6f792c7f9ecdcd8c1cbb
-R b8ba3e500c8750934aa1015f54324e22
+P 2d2f42ca0a24ed8b33f9ad560c76a6c1301c757b
+R d83586425c23d3015fdf0b2326ebc67f
U drh
-Z bf3ffffd67cf82b5b648dccfa3279f49
+Z eeeb8d7f7200949823d967a49549fa65
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.614 2009/07/24 12:35:57 drh Exp $
+** @(#) $Id: pager.c,v 1.615 2009/07/24 16:32:01 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
PgHdr *pPg = 0;
assert( pPager!=0 );
assert( pgno!=0 );
-
- if( (pPager->state!=PAGER_UNLOCK)
- && (pPager->errCode==SQLITE_OK || pPager->errCode==SQLITE_FULL)
- ){
- sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
- }
-
+ assert( pPager->pPCache!=0 );
+ assert( pPager->state > PAGER_UNLOCK );
+ sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
return pPg;
}
assert( pPager->useJournal );
assert( pPager->pInJournal==0 );
- /* If already in the error state, this function is a no-op. */
- if( pPager->errCode ){
- return pPager->errCode;
- }
+ /* If already in the error state, this function is a no-op. But on
+ ** the other hand, this routine is never called if we are already in
+ ** an error state. */
+ if( NEVER(pPager->errCode) ) return pPager->errCode;
/* TODO: Is it really possible to get here with dbSizeValid==0? If not,
** the call to PagerPagecount() can be removed.
Pager *pPager = pPg->pPager;
int rc = SQLITE_OK;
- /* Check for errors
+ /* If an error has been previously detected, we should not be
+ ** calling this routine. Repeat the error for robustness.
*/
- if( pPager->errCode ){
- return pPager->errCode;
- }
- if( pPager->readOnly ){
- return SQLITE_PERM;
- }
+ if( NEVER(pPager->errCode) ) return pPager->errCode;
+
+ /* Higher-level routines never call this function if database is not
+ ** writable. But check anyway, just for robustness. */
+ if( NEVER(pPager->readOnly) ) return SQLITE_PERM;
assert( !pPager->setMaster );
assert( pPgHdr==0 || rc==SQLITE_OK );
/* If page one was fetched successfully, and this function is not
- ** operating in direct-mode, make page 1 writable.
+ ** operating in direct-mode, make page 1 writable. When not in
+ ** direct mode, page 1 is always held in cache and hence the PagerGet()
+ ** above is always successful - hence the ALWAYS on rc==SQLITE_OK.
*/
- if( rc==SQLITE_OK && !DIRECT_MODE ){
+ if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){
rc = sqlite3PagerWrite(pPgHdr);
}
*/
int sqlite3PagerSync(Pager *pPager){
int rc; /* Return code */
- if( MEMDB || pPager->noSync ){
+ assert( !MEMDB );
+ if( pPager->noSync ){
rc = SQLITE_OK;
}else{
rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
){
int rc = SQLITE_OK; /* Return code */
+ /* The dbOrigSize is never set if journal_mode=OFF */
+ assert( pPager->journalMode!=PAGER_JOURNALMODE_OFF || pPager->dbOrigSize==0 );
+
/* 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. */
** that it took at the start of the transaction. Otherwise, the
** calls to sqlite3PagerGet() return zeroed pages instead of
** reading data from the database file.
+ **
+ ** When journal_mode==OFF the dbOrigSize is always zero, so this
+ ** block never runs if journal_mode=OFF.
*/
#ifndef SQLITE_OMIT_AUTOVACUUM
- if( pPager->dbSize<pPager->dbOrigSize
- && pPager->journalMode!=PAGER_JOURNALMODE_OFF
+ if( pPager->dbSize<pPager->dbOrigSize
+ && ALWAYS(pPager->journalMode!=PAGER_JOURNALMODE_OFF)
){
Pgno i; /* Iterator variable */
const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */