aboutsummaryrefslogtreecommitdiff
path: root/src/wal.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-11-13 05:51:37 +0000
committerdrh <drh@noemail.net>2017-11-13 05:51:37 +0000
commit2e9b0923aca34aa5d18a3be65f7e082c45758cc3 (patch)
tree243f3b2e2b9d68263fcc226922c682e7447c3b72 /src/wal.c
parentc05a063c680af17386b221b977bc4eda1cf56e2b (diff)
downloadsqlite-2e9b0923aca34aa5d18a3be65f7e082c45758cc3.tar.gz
sqlite-2e9b0923aca34aa5d18a3be65f7e082c45758cc3.zip
Remove some branches in walTryBeginRead() that were
added by check-in [ce5d13c2de] but became unreachable with the addition of logic in check-in [18b26843] that enabled read-only clients to parse the WAL file into a heap-memory WAL-index, thus guaranteeing that the WAL-index header is always available. FossilOrigin-Name: 9c6b38b9a96c11bdf9db4ea025720a4f49dcb723fa2e2776edc8453bce85c7e3
Diffstat (limited to 'src/wal.c')
-rw-r--r--src/wal.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/wal.c b/src/wal.c
index 6fddf3907..382be4e0c 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -2418,6 +2418,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
assert( pWal->readLock<0 ); /* Not currently locked */
+ /* useWal may only be set for read/write connections */
+ assert( (pWal->readOnly & WAL_SHM_RDONLY)==0 || useWal==0 );
+
/* Take steps to avoid spinning forever if there is a protocol error.
**
** Circumstances that cause a RETRY should only last for the briefest
@@ -2484,9 +2487,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
}
assert( pWal->nWiData>0 );
- assert( pWal->apWiData[0] || (pWal->readOnly & WAL_SHM_RDONLY) );
- pInfo = pWal->apWiData[0] ? walCkptInfo(pWal) : 0;
- if( !useWal && (pInfo==0 || pInfo->nBackfill==pWal->hdr.mxFrame)
+ assert( pWal->apWiData[0]!=0 );
+ pInfo = walCkptInfo(pWal);
+ if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame
#ifdef SQLITE_ENABLE_SNAPSHOT
&& (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0
|| 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr)))
@@ -2498,9 +2501,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
rc = walLockShared(pWal, WAL_READ_LOCK(0));
walShmBarrier(pWal);
if( rc==SQLITE_OK ){
- if( pInfo
- && memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
- ){
+ if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
/* It is not safe to allow the reader to continue here if frames
** may have been appended to the log before READ_LOCK(0) was obtained.
** When holding READ_LOCK(0), the reader ignores the entire log file,