1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-31 18:11:01 +03:00

Automatically close ephemeral b-trees when their last cursor is closed.

FossilOrigin-Name: 39b5af18c0580c8e92516d410f8c465bfec31b2d0be9df1cfd6a1d1a19b4fc14
This commit is contained in:
dan
2021-03-18 14:31:37 +00:00
parent 918232aadb
commit eeee8a5f01
6 changed files with 53 additions and 59 deletions

View File

@@ -2472,20 +2472,15 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
return;
}
assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
assert( pCx->pBtx==0 || pCx->isEphemeral );
switch( pCx->eCurType ){
case CURTYPE_SORTER: {
sqlite3VdbeSorterClose(p->db, pCx);
break;
}
case CURTYPE_BTREE: {
if( pCx->isEphemeral ){
if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);
/* The pCx->pCursor will be close automatically, if it exists, by
** the call above. */
}else{
assert( pCx->uc.pCursor!=0 );
sqlite3BtreeCloseCursor(pCx->uc.pCursor);
}
assert( pCx->uc.pCursor!=0 );
sqlite3BtreeCloseCursor(pCx->uc.pCursor);
break;
}
#ifndef SQLITE_OMIT_VIRTUALTABLE