aboutsummaryrefslogtreecommitdiff
path: root/src/btree.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-05-03 16:56:06 +0000
committerdrh <drh@noemail.net>2018-05-03 16:56:06 +0000
commitd5aa9262a68b04ec0874cd6659dff85e023f30dc (patch)
tree94c029f4ded92d61198df79d1c69b6a8e9c56ebc /src/btree.c
parentda65fc6e329324f0c50165d48c232def3d44140b (diff)
downloadsqlite-d5aa9262a68b04ec0874cd6659dff85e023f30dc.tar.gz
sqlite-d5aa9262a68b04ec0874cd6659dff85e023f30dc.zip
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
Diffstat (limited to 'src/btree.c')
-rw-r--r--src/btree.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c
index 3811c59de..9dc91fe98 100644
--- a/src/btree.c
+++ b/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;
}