mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
New assert() statements to validate OP_OpenEphemeral logic.
FossilOrigin-Name: 6d55c3e238e06c6727f3e816a9268b6222ebfc90ec745bbbd48430bf7b16664c
This commit is contained in:
19
src/btree.c
19
src/btree.c
@ -4746,6 +4746,25 @@ int sqlite3BtreeCursorSize(void){
|
||||
return ROUND8(sizeof(BtCursor));
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/*
|
||||
** Return true if and only if the Btree object will be automatically
|
||||
** closed with the BtCursor closes. This is used within assert() statements
|
||||
** only.
|
||||
*/
|
||||
int sqlite3BtreeClosesWithCursor(
|
||||
Btree *pBtree, /* the btree object */
|
||||
BtCursor *pCur /* Corresponding cursor */
|
||||
){
|
||||
BtShared *pBt = pBtree->pBt;
|
||||
if( (pBt->openFlags & BTREE_SINGLE)==0 ) return 0;
|
||||
if( pBt->pCursor!=pCur ) return 0;
|
||||
if( pCur->pNext!=0 ) return 0;
|
||||
if( pCur->pBtree!=pBtree ) return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Initialize memory that will be converted into a BtCursor object.
|
||||
**
|
||||
|
@ -240,6 +240,9 @@ int sqlite3BtreeCursor(
|
||||
);
|
||||
BtCursor *sqlite3BtreeFakeValidCursor(void);
|
||||
int sqlite3BtreeCursorSize(void);
|
||||
#ifdef SQLITE_DEBUG
|
||||
int sqlite3BtreeClosesWithCursor(Btree*,BtCursor*);
|
||||
#endif
|
||||
void sqlite3BtreeCursorZero(BtCursor*);
|
||||
void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);
|
||||
#ifdef SQLITE_ENABLE_CURSOR_HINTS
|
||||
|
@ -4530,7 +4530,10 @@ case OP_OpenEphemeral: { /* ncycle */
|
||||
}
|
||||
pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
|
||||
if( rc ){
|
||||
assert( !sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) );
|
||||
sqlite3BtreeClose(pCx->ub.pBtx);
|
||||
}else{
|
||||
assert( sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user