ITS#7670 Tweak cursor_del0

Always leave cursor pointing at "next" node, if any.
Find next sibling if we're already at end of current page.
vmware
Howard Chu 11 years ago
parent 6616034eb9
commit e15a90c762
  1. 17
      libraries/liblmdb/mdb.c

@ -7192,6 +7192,7 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf)
int rc; int rc;
MDB_page *mp; MDB_page *mp;
indx_t ki; indx_t ki;
unsigned int nkeys;
mp = mc->mc_pg[mc->mc_top]; mp = mc->mc_pg[mc->mc_top];
ki = mc->mc_ki[mc->mc_top]; ki = mc->mc_ki[mc->mc_top];
@ -7211,18 +7212,18 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf)
rc = mdb_rebalance(mc); rc = mdb_rebalance(mc);
if (rc != MDB_SUCCESS) if (rc != MDB_SUCCESS)
mc->mc_txn->mt_flags |= MDB_TXN_ERROR; mc->mc_txn->mt_flags |= MDB_TXN_ERROR;
/* if mc points past last node in page, invalidate */ else {
else if (mc->mc_ki[mc->mc_top] >= NUMKEYS(mc->mc_pg[mc->mc_top]))
mc->mc_flags &= ~(C_INITIALIZED|C_EOF);
{
/* Adjust other cursors pointing to mp */
MDB_cursor *m2; MDB_cursor *m2;
unsigned int nkeys;
MDB_dbi dbi = mc->mc_dbi; MDB_dbi dbi = mc->mc_dbi;
mp = mc->mc_pg[mc->mc_top]; mp = mc->mc_pg[mc->mc_top];
nkeys = NUMKEYS(mp); nkeys = NUMKEYS(mp);
/* if mc points past last node in page, find next sibling */
if (mc->mc_ki[mc->mc_top] >= nkeys)
mdb_cursor_sibling(mc, 1);
/* Adjust 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) {
if (m2 == mc) if (m2 == mc)
continue; continue;
@ -7232,7 +7233,7 @@ mdb_cursor_del0(MDB_cursor *mc, MDB_node *leaf)
if (m2->mc_ki[mc->mc_top] > ki) if (m2->mc_ki[mc->mc_top] > ki)
m2->mc_ki[mc->mc_top]--; m2->mc_ki[mc->mc_top]--;
if (m2->mc_ki[mc->mc_top] >= nkeys) if (m2->mc_ki[mc->mc_top] >= nkeys)
m2->mc_flags &= ~(C_INITIALIZED|C_EOF); mdb_cursor_sibling(m2, 1);
} }
} }
} }

Loading…
Cancel
Save