mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Have the clearCell() routine return the cell size to the caller, rather
than have the caller make a separate call to cellSizePtr(). FossilOrigin-Name: f21d217583c205dc17f98bb4877fd4ed98cefcb1
This commit is contained in:
22
src/btree.c
22
src/btree.c
@@ -5519,9 +5519,15 @@ static void freePage(MemPage *pPage, int *pRC){
|
||||
}
|
||||
|
||||
/*
|
||||
** Free any overflow pages associated with the given Cell.
|
||||
** Free any overflow pages associated with the given Cell. Write the
|
||||
** local Cell size (the number of bytes on the original page, omitting
|
||||
** overflow) into *pnSize.
|
||||
*/
|
||||
static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||
static int clearCell(
|
||||
MemPage *pPage, /* The page that contains the Cell */
|
||||
unsigned char *pCell, /* First byte of the Cell */
|
||||
u16 *pnSize /* Write the size of the Cell here */
|
||||
){
|
||||
BtShared *pBt = pPage->pBt;
|
||||
CellInfo info;
|
||||
Pgno ovflPgno;
|
||||
@@ -5531,6 +5537,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||
|
||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
||||
btreeParseCellPtr(pPage, pCell, &info);
|
||||
*pnSize = info.nSize;
|
||||
if( info.iOverflow==0 ){
|
||||
return SQLITE_OK; /* No overflow pages. Return without doing anything */
|
||||
}
|
||||
@@ -7166,8 +7173,7 @@ int sqlite3BtreeInsert(
|
||||
if( !pPage->leaf ){
|
||||
memcpy(newCell, oldCell, 4);
|
||||
}
|
||||
szOld = cellSizePtr(pPage, oldCell);
|
||||
rc = clearCell(pPage, oldCell);
|
||||
rc = clearCell(pPage, oldCell, &szOld);
|
||||
dropCell(pPage, idx, szOld, &rc);
|
||||
if( rc ) goto end_insert;
|
||||
}else if( loc<0 && pPage->nCell>0 ){
|
||||
@@ -7229,6 +7235,7 @@ int sqlite3BtreeDelete(BtCursor *pCur){
|
||||
unsigned char *pCell; /* Pointer to cell to delete */
|
||||
int iCellIdx; /* Index of cell to delete */
|
||||
int iCellDepth; /* Depth of node containing pCell */
|
||||
u16 szCell; /* Size of the cell being deleted */
|
||||
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
assert( pBt->inTransaction==TRANS_WRITE );
|
||||
@@ -7277,8 +7284,8 @@ int sqlite3BtreeDelete(BtCursor *pCur){
|
||||
|
||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc ) return rc;
|
||||
rc = clearCell(pPage, pCell);
|
||||
dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
|
||||
rc = clearCell(pPage, pCell, &szCell);
|
||||
dropCell(pPage, iCellIdx, szCell, &rc);
|
||||
if( rc ) return rc;
|
||||
|
||||
/* If the cell deleted was not located on a leaf page, then the cursor
|
||||
@@ -7510,6 +7517,7 @@ static int clearDatabasePage(
|
||||
unsigned char *pCell;
|
||||
int i;
|
||||
int hdr;
|
||||
u16 szCell;
|
||||
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
if( pgno>btreePagecount(pBt) ){
|
||||
@@ -7525,7 +7533,7 @@ static int clearDatabasePage(
|
||||
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
rc = clearCell(pPage, pCell);
|
||||
rc = clearCell(pPage, pCell, &szCell);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
if( !pPage->leaf ){
|
||||
|
Reference in New Issue
Block a user