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

Add experimental fix for corruption detection problem. This may well be revised yet.

FossilOrigin-Name: 1cc4be7ebc463921827e61da724f0de946c061f6
This commit is contained in:
dan
2010-02-25 12:09:16 +00:00
parent 88ba618ee7
commit 887d4b2b43
4 changed files with 48 additions and 12 deletions

View File

@@ -5061,7 +5061,25 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
if( rc ) return rc;
}
rc = freePage2(pBt, pOvfl, ovflPgno);
if( (pOvfl || (pOvfl = btreePageLookup(pBt, ovflPgno)))
&& sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1
){
/* There is no reason any cursor should have an outstanding reference
** to an overflow page belonging to a cell that is being deleted/updated.
** So if there exists more than one reference to this page, then it
** must not really be an overflow page and the database must be corrupt.
** It is helpful to detect this before calling freePage2(), as
** freePage2() may zero the page contents if secure-delete mode is
** enabled. If this 'overflow' page happens to be a page that the
** caller is iterating through or using in some other way, this
** can be problematic.
*/
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = freePage2(pBt, pOvfl, ovflPgno);
}
if( pOvfl ){
sqlite3PagerUnref(pOvfl->pDbPage);
}