mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix various error handling conditions on the cell overwrite optimization.
Fix a test case so that it works with the new optimization. FossilOrigin-Name: f89b54f41405ed7e28132f66b8a0c690a087c2412c8f55790c2beabb0b521645
This commit is contained in:
21
src/btree.c
21
src/btree.c
@@ -8176,7 +8176,9 @@ static int btreeOverwriteContent(
|
||||
if( nData<iAmt ){
|
||||
/* Mixed read data and zeros at the end. Make a recursive call
|
||||
** to write the zeros then fall through to write the real data */
|
||||
btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData, iAmt-nData);
|
||||
int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
|
||||
iAmt-nData);
|
||||
if( rc ) return rc;
|
||||
iAmt = nData;
|
||||
}
|
||||
if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
|
||||
@@ -8219,18 +8221,19 @@ static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
|
||||
rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
|
||||
if( rc ) return rc;
|
||||
if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
if( iOffset+ovflPageSize<nTotal ){
|
||||
ovflPgno = get4byte(pPage->aData);
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
}else{
|
||||
ovflPageSize = nTotal - iOffset;
|
||||
if( iOffset+ovflPageSize<nTotal ){
|
||||
ovflPgno = get4byte(pPage->aData);
|
||||
}else{
|
||||
ovflPageSize = nTotal - iOffset;
|
||||
}
|
||||
rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
|
||||
iOffset, ovflPageSize);
|
||||
}
|
||||
rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
|
||||
iOffset, ovflPageSize);
|
||||
sqlite3PagerUnref(pPage->pDbPage);
|
||||
if( rc ) return rc;
|
||||
iOffset += ovflPageSize;
|
||||
sqlite3PagerUnref(pPage->pDbPage);
|
||||
}while( iOffset<nTotal );
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user