#define C_INITIALIZED 0x01 /**< cursor has been initialized and is valid */
#define C_EOF 0x02 /**< No more data */
#define C_SUB 0x04 /**< Cursor is a sub-cursor */
+#define C_DEL 0x08 /**< last op was a cursor_del */
#define C_SPLITTING 0x20 /**< Cursor is in page_split */
#define C_UNTRACK 0x40 /**< Un-track cursor when closing */
/** @} */
}
DPRINTF(("cursor_next: top page is %"Z"u in cursor %p", mp->mp_pgno, (void *) mc));
+ if (mc->mc_flags & C_DEL)
+ goto skip;
if (mc->mc_ki[mc->mc_top] + 1u >= NUMKEYS(mp)) {
DPUTS("=====> move to next sibling page");
} else
mc->mc_ki[mc->mc_top]++;
+skip:
DPRINTF(("==> cursor points to page %"Z"u with %u keys, key index %u",
mp->mp_pgno, NUMKEYS(mp), mc->mc_ki[mc->mc_top]));
MDB_GET_KEY(leaf, key);
if (data) {
if (F_ISSET(leaf->mn_flags, F_DUPDATA)) {
+ if (mc->mc_flags & C_DEL)
+ mdb_xcursor_init1(mc, leaf);
rc = mdb_cursor_get(&mc->mc_xcursor->mx_cursor, data, NULL, MDB_GET_CURRENT);
} else {
rc = mdb_node_read(mc->mc_txn, leaf, data);
break;
}
+ if (mc->mc_flags & C_DEL)
+ mc->mc_flags ^= C_DEL;
+
return rc;
}
}
}
mc->mc_db->md_entries--;
+ mc->mc_flags |= C_DEL;
return rc;
}
/* otherwise fall thru and delete the sub-DB */
if (!(m2->mc_flags & C_INITIALIZED))
continue;
if (m2->mc_pg[mc->mc_top] == mp) {
- if (m2->mc_ki[mc->mc_top] > ki)
- m2->mc_ki[mc->mc_top]--;
+ if (m2->mc_ki[mc->mc_top] >= ki) {
+ m2->mc_flags |= C_DEL;
+ if (m2->mc_ki[mc->mc_top] > ki)
+ m2->mc_ki[mc->mc_top]--;
+ }
if (m2->mc_ki[mc->mc_top] >= nkeys)
mdb_cursor_sibling(m2, 1);
}
}
+ mc->mc_flags |= C_DEL;
}
return rc;