mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Avoid leaving a suspect page in the page-cache if an error occurs during sqlite3PagerAcquire(). (CVS 6922)
FossilOrigin-Name: 2594f01c73301f9432be9d007a079a19a3d383f9
This commit is contained in:
22
src/pager.c
22
src/pager.c
@@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.612 2009/07/22 13:19:20 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.613 2009/07/22 16:41:15 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
#include "sqliteInt.h"
|
||||
@@ -3772,18 +3772,6 @@ static void pagerUnlockIfUnused(Pager *pPager){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Drop a page from the cache using sqlite3PcacheDrop().
|
||||
**
|
||||
** If this means there are now no pages with references to them, a rollback
|
||||
** occurs and the lock on the database is removed.
|
||||
*/
|
||||
static void pagerDropPage(DbPage *pPg){
|
||||
Pager *pPager = pPg->pPager;
|
||||
sqlite3PcacheDrop(pPg);
|
||||
pagerUnlockIfUnused(pPager);
|
||||
}
|
||||
|
||||
/*
|
||||
** Acquire a reference to page number pgno in pager pPager (a page
|
||||
** reference has type DbPage*). If the requested reference is
|
||||
@@ -3871,6 +3859,7 @@ int sqlite3PagerAcquire(
|
||||
if( (*ppPage)->pPager ){
|
||||
/* In this case the pcache already contains an initialized copy of
|
||||
** the page. Return without further ado. */
|
||||
assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
|
||||
PAGER_INCR(pPager->nHit);
|
||||
return SQLITE_OK;
|
||||
|
||||
@@ -3923,8 +3912,6 @@ int sqlite3PagerAcquire(
|
||||
assert( pPg->pPager==pPager );
|
||||
rc = readDbPage(pPg);
|
||||
if( rc!=SQLITE_OK ){
|
||||
pagerDropPage(pPg);
|
||||
pPg = 0;
|
||||
goto pager_acquire_err;
|
||||
}
|
||||
}
|
||||
@@ -3937,8 +3924,11 @@ int sqlite3PagerAcquire(
|
||||
|
||||
pager_acquire_err:
|
||||
assert( rc!=SQLITE_OK );
|
||||
sqlite3PagerUnref(pPg);
|
||||
if( pPg ){
|
||||
sqlite3PcacheDrop(pPg);
|
||||
}
|
||||
pagerUnlockIfUnused(pPager);
|
||||
|
||||
*ppPage = 0;
|
||||
return rc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user