Fix mdb_page_merge

Similar to prev commit for mdb_node_move, the call of
mdb_page_serch_lowest() was leaving csrc unusable.
incre
Howard Chu 11 years ago
parent 79e8462d74
commit eebbd22c2f
  1. 15
      libraries/liblmdb/mdb.c

@ -7215,22 +7215,21 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst)
for (i = 0; i < NUMKEYS(csrc->mc_pg[csrc->mc_top]); i++, j++) { for (i = 0; i < NUMKEYS(csrc->mc_pg[csrc->mc_top]); i++, j++) {
srcnode = NODEPTR(csrc->mc_pg[csrc->mc_top], i); srcnode = NODEPTR(csrc->mc_pg[csrc->mc_top], i);
if (i == 0 && IS_BRANCH(csrc->mc_pg[csrc->mc_top])) { if (i == 0 && IS_BRANCH(csrc->mc_pg[csrc->mc_top])) {
unsigned int snum = csrc->mc_snum; MDB_cursor mn;
MDB_node *s2; MDB_node *s2;
mdb_cursor_copy(csrc, &mn);
/* must find the lowest key below src */ /* must find the lowest key below src */
rc = mdb_page_search_lowest(csrc); rc = mdb_page_search_lowest(&mn);
if (rc) if (rc)
return rc; return rc;
if (IS_LEAF2(csrc->mc_pg[csrc->mc_top])) { if (IS_LEAF2(mn.mc_pg[mn.mc_top])) {
key.mv_size = csrc->mc_db->md_pad; key.mv_size = mn.mc_db->md_pad;
key.mv_data = LEAF2KEY(csrc->mc_pg[csrc->mc_top], 0, key.mv_size); key.mv_data = LEAF2KEY(mn.mc_pg[mn.mc_top], 0, key.mv_size);
} else { } else {
s2 = NODEPTR(csrc->mc_pg[csrc->mc_top], 0); s2 = NODEPTR(mn.mc_pg[mn.mc_top], 0);
key.mv_size = NODEKSZ(s2); key.mv_size = NODEKSZ(s2);
key.mv_data = NODEKEY(s2); key.mv_data = NODEKEY(s2);
} }
csrc->mc_snum = snum--;
csrc->mc_top = snum;
} else { } else {
key.mv_size = srcnode->mn_ksize; key.mv_size = srcnode->mn_ksize;
key.mv_data = NODEKEY(srcnode); key.mv_data = NODEKEY(srcnode);

Loading…
Cancel
Save