mdbx: fix tracking inside mdbx_cursor_del().

Change-Id: Ib1b3f00270d6aec18428da4caf0f173378b9b5b5
This commit is contained in:
Leonid Yuriev 2018-09-12 05:21:50 +03:00 committed by Leo Yuriev
parent 3b80b358e5
commit 70c796463b

View File

@ -10263,6 +10263,7 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
return rc; return rc;
} }
ki = mc->mc_ki[mc->mc_top];
mp = mc->mc_pg[mc->mc_top]; mp = mc->mc_pg[mc->mc_top];
mdbx_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top])); mdbx_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top]));
nkeys = NUMKEYS(mp); nkeys = NUMKEYS(mp);
@ -10273,23 +10274,24 @@ static int mdbx_cursor_del0(MDBX_cursor *mc) {
/* Adjust THIS and other cursors pointing to mp */ /* Adjust THIS and other cursors pointing to mp */
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) { for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2 = m2->mc_next) {
m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2; m3 = (mc->mc_flags & C_SUB) ? &m2->mc_xcursor->mx_cursor : m2;
if (!(m2->mc_flags & m3->mc_flags & C_INITIALIZED)) if (m3 == mc || !(m2->mc_flags & m3->mc_flags & C_INITIALIZED))
continue; continue;
if (m3->mc_snum < mc->mc_snum) if (m3->mc_snum < mc->mc_snum)
continue; continue;
if (m3->mc_pg[mc->mc_top] == mp) { if (m3->mc_pg[mc->mc_top] == mp) {
/* if m3 points past last node in page, find next sibling */ /* if m3 points past last node in page, find next sibling */
if (m3->mc_ki[mc->mc_top] >= mc->mc_ki[mc->mc_top]) { if (m3->mc_ki[mc->mc_top] >= nkeys) {
if (m3->mc_ki[mc->mc_top] >= nkeys) { rc = mdbx_cursor_sibling(m3, true);
rc = mdbx_cursor_sibling(m3, true); if (rc == MDBX_NOTFOUND) {
if (rc == MDBX_NOTFOUND) { m3->mc_flags |= C_EOF;
m3->mc_flags |= C_EOF; rc = MDBX_SUCCESS;
rc = MDBX_SUCCESS; continue;
continue; } else if (unlikely(rc != MDBX_SUCCESS))
} else if (unlikely(rc != MDBX_SUCCESS)) break;
break; }
} if (m3->mc_ki[mc->mc_top] >= ki || m3->mc_pg[mc->mc_top] != mp) {
if (mc->mc_db->md_flags & MDBX_DUPSORT) { if ((mc->mc_db->md_flags & MDBX_DUPSORT) != 0 &&
(m3->mc_flags & C_EOF) == 0) {
MDBX_node *node = MDBX_node *node =
NODEPTR(m3->mc_pg[m3->mc_top], m3->mc_ki[m3->mc_top]); NODEPTR(m3->mc_pg[m3->mc_top], m3->mc_ki[m3->mc_top]);
/* If this node has dupdata, it may need to be reinited /* If this node has dupdata, it may need to be reinited