1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Simplifications to pager.c in support of structural coverage testing. (CVS 6927)

FossilOrigin-Name: 7222ad2667b95d6021d9ae47f548b76b224f46aa
This commit is contained in:
drh
2009-07-24 16:32:00 +00:00
parent b480dc2393
commit ad7516c45f
4 changed files with 41 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
C Simplifications\sand\scomment\simprovements\sin\spager.c.\s(CVS\s6926) C Simplifications\sto\spager.c\sin\ssupport\sof\sstructural\scoverage\stesting.\s(CVS\s6927)
D 2009-07-24T12:35:57 D 2009-07-24T16:32:01
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -147,7 +147,7 @@ F src/os_common.h 8c61457df58f1a4bd5f5adc3e90e01b37bf7afbc
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5 F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
F src/os_unix.c cdb2a08b9ce4aa13b3f7b91d4dd60fb48be9f56a F src/os_unix.c cdb2a08b9ce4aa13b3f7b91d4dd60fb48be9f56a
F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405 F src/os_win.c 725c38a524d168ce280446ad8761d731bc516405
F src/pager.c cc446ee38f0caf5fab47353f769711e02fda7a0d F src/pager.c 80910e68f6bde91dc96a3dcb5d8e5edf3505fa0d
F src/pager.h 5bd96ed838e4156e0effa5ffe746bce4c0112c24 F src/pager.h 5bd96ed838e4156e0effa5ffe746bce4c0112c24
F src/parse.y bcd46d43fbd23a22b8c020a3eb1806b794794ed5 F src/parse.y bcd46d43fbd23a22b8c020a3eb1806b794794ed5
F src/pcache.c 1dae135b70a029f81ed66f6e9b5d0db91480d5d0 F src/pcache.c 1dae135b70a029f81ed66f6e9b5d0db91480d5d0
@@ -492,7 +492,7 @@ F test/notify2.test 195a467e021f74197be2c4fb02d6dee644b8d8db
F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82 F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/null.test a8b09b8ed87852742343b33441a9240022108993
F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec F test/openv2.test af02ed0a9cbc0d2a61b8f35171d4d117e588e4ec
F test/pager.test d04982df84334a9ed272ed2943b61985be5377ee F test/pager.test 2d0abb66c8967ffac4558c0530b31c28706b5e64
F test/pager2.test d4b7f6b70ff018b9995e622a32526b275f515042 F test/pager2.test d4b7f6b70ff018b9995e622a32526b275f515042
F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4 F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
@@ -741,7 +741,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
P 5ba880dde8a219543ced6f792c7f9ecdcd8c1cbb P 2d2f42ca0a24ed8b33f9ad560c76a6c1301c757b
R b8ba3e500c8750934aa1015f54324e22 R d83586425c23d3015fdf0b2326ebc67f
U drh U drh
Z bf3ffffd67cf82b5b648dccfa3279f49 Z eeeb8d7f7200949823d967a49549fa65

View File

@@ -1 +1 @@
2d2f42ca0a24ed8b33f9ad560c76a6c1301c757b 7222ad2667b95d6021d9ae47f548b76b224f46aa

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** 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 #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -3950,13 +3950,9 @@ DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
PgHdr *pPg = 0; PgHdr *pPg = 0;
assert( pPager!=0 ); assert( pPager!=0 );
assert( pgno!=0 ); assert( pgno!=0 );
assert( pPager->pPCache!=0 );
if( (pPager->state!=PAGER_UNLOCK) assert( pPager->state > PAGER_UNLOCK );
&& (pPager->errCode==SQLITE_OK || pPager->errCode==SQLITE_FULL) sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
){
sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
}
return pPg; return pPg;
} }
@@ -4027,10 +4023,10 @@ static int pager_open_journal(Pager *pPager){
assert( pPager->useJournal ); assert( pPager->useJournal );
assert( pPager->pInJournal==0 ); assert( pPager->pInJournal==0 );
/* If already in the error state, this function is a no-op. */ /* If already in the error state, this function is a no-op. But on
if( pPager->errCode ){ ** the other hand, this routine is never called if we are already in
return pPager->errCode; ** an error state. */
} if( NEVER(pPager->errCode) ) return pPager->errCode;
/* TODO: Is it really possible to get here with dbSizeValid==0? If not, /* TODO: Is it really possible to get here with dbSizeValid==0? If not,
** the call to PagerPagecount() can be removed. ** the call to PagerPagecount() can be removed.
@@ -4184,14 +4180,14 @@ static int pager_write(PgHdr *pPg){
Pager *pPager = pPg->pPager; Pager *pPager = pPg->pPager;
int rc = SQLITE_OK; 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 ){ if( NEVER(pPager->errCode) ) return pPager->errCode;
return pPager->errCode;
} /* Higher-level routines never call this function if database is not
if( pPager->readOnly ){ ** writable. But check anyway, just for robustness. */
return SQLITE_PERM; if( NEVER(pPager->readOnly) ) return SQLITE_PERM;
}
assert( !pPager->setMaster ); assert( !pPager->setMaster );
@@ -4504,9 +4500,11 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
assert( pPgHdr==0 || rc==SQLITE_OK ); assert( pPgHdr==0 || rc==SQLITE_OK );
/* If page one was fetched successfully, and this function is not /* 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); rc = sqlite3PagerWrite(pPgHdr);
} }
@@ -4544,7 +4542,8 @@ static int pager_incr_changecounter(Pager *pPager, int isDirectMode){
*/ */
int sqlite3PagerSync(Pager *pPager){ int sqlite3PagerSync(Pager *pPager){
int rc; /* Return code */ int rc; /* Return code */
if( MEMDB || pPager->noSync ){ assert( !MEMDB );
if( pPager->noSync ){
rc = SQLITE_OK; rc = SQLITE_OK;
}else{ }else{
rc = sqlite3OsSync(pPager->fd, pPager->sync_flags); rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
@@ -4585,6 +4584,9 @@ int sqlite3PagerCommitPhaseOne(
){ ){
int rc = SQLITE_OK; /* Return code */ 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 /* If a prior error occurred, this routine should not be called. ROLLBACK
** is the appropriate response to an error, not COMMIT. Guard against ** is the appropriate response to an error, not COMMIT. Guard against
** coding errors by repeating the prior error. */ ** coding errors by repeating the prior error. */
@@ -4659,10 +4661,13 @@ int sqlite3PagerCommitPhaseOne(
** that it took at the start of the transaction. Otherwise, the ** that it took at the start of the transaction. Otherwise, the
** calls to sqlite3PagerGet() return zeroed pages instead of ** calls to sqlite3PagerGet() return zeroed pages instead of
** reading data from the database file. ** 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 #ifndef SQLITE_OMIT_AUTOVACUUM
if( pPager->dbSize<pPager->dbOrigSize if( pPager->dbSize<pPager->dbOrigSize
&& pPager->journalMode!=PAGER_JOURNALMODE_OFF && ALWAYS(pPager->journalMode!=PAGER_JOURNALMODE_OFF)
){ ){
Pgno i; /* Iterator variable */ Pgno i; /* Iterator variable */
const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */ const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem. # focus of this script is page cache subsystem.
# #
# $Id: pager.test,v 1.35 2009/06/05 17:09:12 drh Exp $ # $Id: pager.test,v 1.36 2009/07/24 16:32:01 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
@@ -55,9 +55,9 @@ do_test pager-2.1 {
# } msg] # } msg]
# lappend v $msg # lappend v $msg
#} {1 SQLITE_ERROR} #} {1 SQLITE_ERROR}
do_test pager-2.3.1 { #do_test pager-2.3.1 {
set ::gx [page_lookup $::p1 1] # set ::gx [page_lookup $::p1 1]
} {} #} {}
do_test pager-2.3.2 { do_test pager-2.3.2 {
pager_stats $::p1 pager_stats $::p1
} {ref 0 page 0 max 10 size -1 state 0 err 0 hit 0 miss 0 ovfl 0} } {ref 0 page 0 max 10 size -1 state 0 err 0 hit 0 miss 0 ovfl 0}