ITS#8300 more for prev commit

Just tell explicitly which direction we moved/merged from
vl32b
Howard Chu 9 years ago
parent 946e4d3b21
commit d6ae2553df
  1. 16
      libraries/liblmdb/mdb.c

@ -1396,7 +1396,7 @@ static int mdb_node_add(MDB_cursor *mc, indx_t indx,
MDB_val *key, MDB_val *data, pgno_t pgno, unsigned int flags); MDB_val *key, MDB_val *data, pgno_t pgno, unsigned int flags);
static void mdb_node_del(MDB_cursor *mc, int ksize); static void mdb_node_del(MDB_cursor *mc, int ksize);
static void mdb_node_shrink(MDB_page *mp, indx_t indx); static void mdb_node_shrink(MDB_page *mp, indx_t indx);
static int mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst); static int mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft);
static int mdb_node_read(MDB_txn *txn, MDB_node *leaf, MDB_val *data); static int mdb_node_read(MDB_txn *txn, MDB_node *leaf, MDB_val *data);
static size_t mdb_leaf_size(MDB_env *env, MDB_val *key, MDB_val *data); static size_t mdb_leaf_size(MDB_env *env, MDB_val *key, MDB_val *data);
static size_t mdb_branch_size(MDB_env *env, MDB_val *key); static size_t mdb_branch_size(MDB_env *env, MDB_val *key);
@ -7647,7 +7647,7 @@ mdb_cursor_copy(const MDB_cursor *csrc, MDB_cursor *cdst);
/** Move a node from csrc to cdst. /** Move a node from csrc to cdst.
*/ */
static int static int
mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst) mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
{ {
MDB_node *srcnode; MDB_node *srcnode;
MDB_val key, data; MDB_val key, data;
@ -7749,7 +7749,7 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst)
mps = csrc->mc_pg[csrc->mc_top]; mps = csrc->mc_pg[csrc->mc_top];
/* If we're adding on the left, bump others up */ /* If we're adding on the left, bump others up */
if (!cdst->mc_ki[csrc->mc_top]) { if (fromleft) {
mpd = cdst->mc_pg[csrc->mc_top]; mpd = cdst->mc_pg[csrc->mc_top];
for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) { for (m2 = csrc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
if (csrc->mc_flags & C_SUB) if (csrc->mc_flags & C_SUB)
@ -8030,7 +8030,7 @@ static int
mdb_rebalance(MDB_cursor *mc) mdb_rebalance(MDB_cursor *mc)
{ {
MDB_node *node; MDB_node *node;
int rc; int rc, fromleft;
unsigned int ptop, minkeys, thresh; unsigned int ptop, minkeys, thresh;
MDB_cursor mn; MDB_cursor mn;
indx_t oldki; indx_t oldki;
@ -8163,6 +8163,7 @@ mdb_rebalance(MDB_cursor *mc)
return rc; return rc;
mn.mc_ki[mn.mc_top] = 0; mn.mc_ki[mn.mc_top] = 0;
mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]); mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]);
fromleft = 0;
} else { } else {
/* There is at least one neighbor to the left. /* There is at least one neighbor to the left.
*/ */
@ -8174,6 +8175,7 @@ mdb_rebalance(MDB_cursor *mc)
return rc; return rc;
mn.mc_ki[mn.mc_top] = NUMKEYS(mn.mc_pg[mn.mc_top]) - 1; mn.mc_ki[mn.mc_top] = NUMKEYS(mn.mc_pg[mn.mc_top]) - 1;
mc->mc_ki[mc->mc_top] = 0; mc->mc_ki[mc->mc_top] = 0;
fromleft = 1;
} }
DPRINTF(("found neighbor page %"Z"u (%u keys, %.1f%% full)", DPRINTF(("found neighbor page %"Z"u (%u keys, %.1f%% full)",
@ -8185,13 +8187,13 @@ mdb_rebalance(MDB_cursor *mc)
* (A branch page must never have less than 2 keys.) * (A branch page must never have less than 2 keys.)
*/ */
if (PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) >= thresh && NUMKEYS(mn.mc_pg[mn.mc_top]) > minkeys) { if (PAGEFILL(mc->mc_txn->mt_env, mn.mc_pg[mn.mc_top]) >= thresh && NUMKEYS(mn.mc_pg[mn.mc_top]) > minkeys) {
rc = mdb_node_move(&mn, mc); rc = mdb_node_move(&mn, mc, fromleft);
if (!mc->mc_ki[mc->mc_top]) { if (fromleft) {
/* if we inserted on left, bump position up */ /* if we inserted on left, bump position up */
oldki++; oldki++;
} }
} else { } else {
if (mc->mc_ki[ptop] == 0) { if (!fromleft) {
rc = mdb_page_merge(&mn, mc); rc = mdb_page_merge(&mn, mc);
} else { } else {
MDB_cursor dummy; MDB_cursor dummy;

Loading…
Cancel
Save