mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Add a new hint bit on the flags parameter of sqlite3BtreeDelete(). The new
BTREE_IDXDELETE bit indicates that the call is to delete an index entry corresponding to a table row that has already been deleted. FossilOrigin-Name: ac2cbadd8000947c097da5b00c00090fe58fdcff
This commit is contained in:
41
src/btree.c
41
src/btree.c
@@ -4049,13 +4049,13 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
|
||||
** on the database already. If a write-cursor is requested, then
|
||||
** the caller is assumed to have an open write transaction.
|
||||
**
|
||||
** If wrFlag==0, then the cursor can only be used for reading.
|
||||
** If wrFlag==1, then the cursor can be used for reading or for
|
||||
** writing if other conditions for writing are also met. These
|
||||
** are the conditions that must be met in order for writing to
|
||||
** be allowed:
|
||||
** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only
|
||||
** be used for reading. If the BTREE_WRCSR bit is set, then the cursor
|
||||
** can be used for reading or for writing if other conditions for writing
|
||||
** are also met. These are the conditions that must be met in order
|
||||
** for writing to be allowed:
|
||||
**
|
||||
** 1: The cursor must have been opened with wrFlag==1
|
||||
** 1: The cursor must have been opened with wrFlag containing BTREE_WRCSR
|
||||
**
|
||||
** 2: Other database connections that share the same pager cache
|
||||
** but which are not in the READ_UNCOMMITTED state may not have
|
||||
@@ -4067,6 +4067,16 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
|
||||
**
|
||||
** 4: There must be an active transaction.
|
||||
**
|
||||
** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR
|
||||
** is set. If FORDELETE is set, that is a hint to the implementation that
|
||||
** this cursor will only be used to seek to and delete entries of an index
|
||||
** as part of a larger DELETE statement. The FORDELETE hint is not used by
|
||||
** this implementation. But in a hypothetical alternative storage engine
|
||||
** in which index entries are automatically deleted when corresponding table
|
||||
** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE
|
||||
** operations on this cursor can be no-ops and all READ operations can
|
||||
** return a null row (2-bytes: 0x01 0x00).
|
||||
**
|
||||
** No checking is done to make sure that page iTable really is the
|
||||
** root page of a b-tree. If it is not, then the cursor acquired
|
||||
** will not work correctly.
|
||||
@@ -8082,13 +8092,18 @@ end_insert:
|
||||
/*
|
||||
** Delete the entry that the cursor is pointing to.
|
||||
**
|
||||
** If the second parameter is zero, then the cursor is left pointing at an
|
||||
** arbitrary location after the delete. If it is non-zero, then the cursor
|
||||
** is left in a state such that the next call to BtreeNext() or BtreePrev()
|
||||
** moves it to the same row as it would if the call to BtreeDelete() had
|
||||
** been omitted.
|
||||
** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then
|
||||
** the cursor is left pointing at an arbitrary location after the delete.
|
||||
** But if that bit is set, then the cursor is left in a state such that
|
||||
** the next call to BtreeNext() or BtreePrev() moves it to the same row
|
||||
** as it would have been on if the call to BtreeDelete() had been omitted.
|
||||
**
|
||||
** The BTREE_IDXDELETE bit of flags indicates that this is a delete of
|
||||
** an index entry where the corresponding table row has already been deleted.
|
||||
** The BTREE_IDXDELETE bit is a hint that is not used by this implementation,
|
||||
** but which might be used by alternative storage engines.
|
||||
*/
|
||||
int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){
|
||||
int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
Btree *p = pCur->pBtree;
|
||||
BtShared *pBt = p->pBt;
|
||||
int rc; /* Return code */
|
||||
@@ -8098,6 +8113,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){
|
||||
int iCellDepth; /* Depth of node containing pCell */
|
||||
u16 szCell; /* Size of the cell being deleted */
|
||||
int bSkipnext = 0; /* Leaf cursor in SKIPNEXT state */
|
||||
u8 bPreserve = flags & BTREE_SAVEPOSITION; /* Keep cursor valid */
|
||||
|
||||
assert( cursorOwnsBtShared(pCur) );
|
||||
assert( pBt->inTransaction==TRANS_WRITE );
|
||||
@@ -8107,6 +8123,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, int bPreserve){
|
||||
assert( !hasReadConflicts(p, pCur->pgnoRoot) );
|
||||
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_IDXDELETE))==0 );
|
||||
|
||||
iCellDepth = pCur->iPage;
|
||||
iCellIdx = pCur->aiIdx[iCellDepth];
|
||||
|
Reference in New Issue
Block a user