1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Further sanity checking of the OpenDup cursors.

FossilOrigin-Name: 0ec71cf16983697f68ab8d921d80a5f39611e4cb5e6e19cbc4a9ad6d49bfc835
This commit is contained in:
drh
2021-03-18 15:42:59 +00:00
parent eeee8a5f01
commit 5a4a15fd2e
5 changed files with 30 additions and 27 deletions

View File

@@ -2737,20 +2737,24 @@ static void freeTempSpace(BtShared *pBt){
*/
int sqlite3BtreeClose(Btree *p){
BtShared *pBt = p->pBt;
BtCursor *pCur;
/* Close all cursors opened via this handle. */
assert( sqlite3_mutex_held(p->db->mutex) );
sqlite3BtreeEnter(p);
pBt->openFlags &= ~BTREE_SINGLE;
pCur = pBt->pCursor;
while( pCur ){
BtCursor *pTmp = pCur;
pCur = pCur->pNext;
if( pTmp->pBtree==p ){
sqlite3BtreeCloseCursor(pTmp);
/* Verify that no other cursors have this Btree open */
#ifdef SQLITE_DEBUG
{
BtCursor *pCur = pBt->pCursor;
while( pCur ){
BtCursor *pTmp = pCur;
pCur = pCur->pNext;
assert( pTmp->pBtree!=p );
}
}
#endif
pBt->openFlags &= ~BTREE_SINGLE;
/* Rollback any active transaction and free the handle structure.
** The call to sqlite3BtreeRollback() drops any table-locks held by