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

In the pager, avoid checking for the illegal page number 0 except when creating

a new page.

FossilOrigin-Name: dee20ba982125ea98c280ad1571789af0f393903
This commit is contained in:
drh
2016-12-13 18:34:01 +00:00
parent d5df3ff2cc
commit cbed604f52
4 changed files with 18 additions and 21 deletions

View File

@@ -5366,15 +5366,11 @@ static int getPageNormal(
u8 noContent; /* True if PAGER_GET_NOCONTENT is set */
sqlite3_pcache_page *pBase;
if( pgno==0 ){
return SQLITE_CORRUPT_BKPT;
}
assert( pPager->errCode==SQLITE_OK );
assert( pPager->eState>=PAGER_READER );
assert( assert_pager_state(pPager) );
assert( pPager->hasHeldSharedLock==1 );
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
if( pBase==0 ){
pPg = 0;
@@ -5399,17 +5395,19 @@ static int getPageNormal(
}else{
/* The pager cache has created a new page. Its content needs to
** be initialized. */
pPg->pPager = pPager;
/* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page
** number greater than this, or the unused locking-page, is requested. */
if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){
** be initialized. But first some error checks:
**
** (1) Minimum page number is 1
** (2) The maximum page number is 2^31
** (3) Never try to fetch the locking page
*/
if( pgno==0 || pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){
rc = SQLITE_CORRUPT_BKPT;
goto pager_acquire_err;
}
pPg->pPager = pPager;
assert( !isOpen(pPager->fd) || !MEMDB );
noContent = (flags & PAGER_GET_NOCONTENT)!=0;
if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){