From: Howard Chu Date: Wed, 9 May 2012 18:24:25 +0000 (-0700) Subject: ITS#7266 fix rebalance for LEAF2 pages X-Git-Tag: OPENLDAP_REL_ENG_2_4_32~125^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eeec509150c3198047ec349eaf80eea90569ed2d;p=openldap ITS#7266 fix rebalance for LEAF2 pages --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index 3a13065e68..5bdf8d1230 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -5214,9 +5214,14 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst) MDB_node *s2; /* must find the lowest key below src */ mdb_page_search_root(csrc, NULL, 0); - s2 = NODEPTR(csrc->mc_pg[csrc->mc_top], 0); - key.mv_size = NODEKSZ(s2); - key.mv_data = NODEKEY(s2); + if (IS_LEAF2(csrc->mc_pg[csrc->mc_top])) { + key.mv_size = csrc->mc_db->md_pad; + key.mv_data = LEAF2KEY(csrc->mc_pg[csrc->mc_top], 0, key.mv_size); + } else { + s2 = NODEPTR(csrc->mc_pg[csrc->mc_top], 0); + key.mv_size = NODEKSZ(s2); + key.mv_data = NODEKEY(s2); + } csrc->mc_snum = snum--; csrc->mc_top = snum; } else { @@ -5232,9 +5237,14 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst) MDB_val bkey; /* must find the lowest key below dst */ mdb_page_search_root(cdst, NULL, 0); - s2 = NODEPTR(cdst->mc_pg[cdst->mc_top], 0); - bkey.mv_size = NODEKSZ(s2); - bkey.mv_data = NODEKEY(s2); + if (IS_LEAF2(cdst->mc_pg[cdst->mc_top])) { + bkey.mv_size = cdst->mc_db->md_pad; + bkey.mv_data = LEAF2KEY(cdst->mc_pg[cdst->mc_top], 0, bkey.mv_size); + } else { + s2 = NODEPTR(cdst->mc_pg[cdst->mc_top], 0); + bkey.mv_size = NODEKSZ(s2); + bkey.mv_data = NODEKEY(s2); + } cdst->mc_snum = snum--; cdst->mc_top = snum; rc = mdb_update_key(cdst->mc_pg[cdst->mc_top], 0, &bkey); @@ -5377,9 +5387,14 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst) MDB_node *s2; /* must find the lowest key below src */ mdb_page_search_root(csrc, NULL, 0); - s2 = NODEPTR(csrc->mc_pg[csrc->mc_top], 0); - key.mv_size = NODEKSZ(s2); - key.mv_data = NODEKEY(s2); + if (IS_LEAF2(csrc->mc_pg[csrc->mc_top])) { + key.mv_size = csrc->mc_db->md_pad; + key.mv_data = LEAF2KEY(csrc->mc_pg[csrc->mc_top], 0, key.mv_size); + } else { + s2 = NODEPTR(csrc->mc_pg[csrc->mc_top], 0); + key.mv_size = NODEKSZ(s2); + key.mv_data = NODEKEY(s2); + } csrc->mc_snum = snum--; csrc->mc_top = snum; } else {