mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Avoid unnecessary blob handle invalidation when changes are made to an
unrelated table. FossilOrigin-Name: 4a01880b62706c12d6f16f7c2b5c8b0dc67a9a8a0a48c5b42451e1a133e85611
This commit is contained in:
11
src/btree.c
11
src/btree.c
@@ -499,6 +499,7 @@ static void invalidateAllOverflowCache(BtShared *pBt){
|
||||
*/
|
||||
static void invalidateIncrblobCursors(
|
||||
Btree *pBtree, /* The database file to check */
|
||||
Pgno pgnoRoot, /* The table that might be changing */
|
||||
i64 iRow, /* The rowid that might be changing */
|
||||
int isClearTable /* True if all rows are being deleted */
|
||||
){
|
||||
@@ -509,7 +510,7 @@ static void invalidateIncrblobCursors(
|
||||
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
|
||||
if( (p->curFlags & BTCF_Incrblob)!=0 ){
|
||||
pBtree->hasIncrblobCur = 1;
|
||||
if( isClearTable || p->info.nKey==iRow ){
|
||||
if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){
|
||||
p->eState = CURSOR_INVALID;
|
||||
}
|
||||
}
|
||||
@@ -518,7 +519,7 @@ static void invalidateIncrblobCursors(
|
||||
|
||||
#else
|
||||
/* Stub function when INCRBLOB is omitted */
|
||||
#define invalidateIncrblobCursors(x,y,z)
|
||||
#define invalidateIncrblobCursors(w,x,y,z)
|
||||
#endif /* SQLITE_OMIT_INCRBLOB */
|
||||
|
||||
/*
|
||||
@@ -8110,7 +8111,7 @@ int sqlite3BtreeInsert(
|
||||
assert( pX->pKey==0 );
|
||||
/* If this is an insert into a table b-tree, invalidate any incrblob
|
||||
** cursors open on the row being replaced */
|
||||
invalidateIncrblobCursors(p, pX->nKey, 0);
|
||||
invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);
|
||||
|
||||
/* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
|
||||
** to a row with the same key as the new entry being inserted. */
|
||||
@@ -8340,7 +8341,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
/* If this is a delete operation to remove a row from a table b-tree,
|
||||
** invalidate any incrblob cursors open on the row being deleted. */
|
||||
if( pCur->pKeyInfo==0 ){
|
||||
invalidateIncrblobCursors(p, pCur->info.nKey, 0);
|
||||
invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);
|
||||
}
|
||||
|
||||
/* Make the page containing the entry to be deleted writable. Then free any
|
||||
@@ -8667,7 +8668,7 @@ int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
|
||||
/* Invalidate all incrblob cursors open on table iTable (assuming iTable
|
||||
** is the root of a table b-tree - if it is not, the following call is
|
||||
** a no-op). */
|
||||
invalidateIncrblobCursors(p, 0, 1);
|
||||
invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
|
||||
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
|
Reference in New Issue
Block a user