From 331bf92df58eefbf2272a235a7a19ef0f6fe7493 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 6 Oct 2011 18:53:07 -0700 Subject: [PATCH] Fix page_split with MDB_RESERVE --- libraries/libmdb/mdb.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index dc333e9..5ef3022 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -5520,10 +5520,6 @@ newsep: rc = mdb_node_add(mc, j, &rkey, rdata, pgno, flags); } - /* reset back to original page */ - if (newindx < split_indx) - mc->mc_pg[mc->mc_top] = mp; - nkeys = NUMKEYS(copy); for (i=0; imp_ptrs[i] = copy->mp_ptrs[i]; @@ -5532,6 +5528,16 @@ newsep: memcpy(NODEPTR(mp, nkeys-1), NODEPTR(copy, nkeys-1), mc->mc_txn->mt_env->me_psize - copy->mp_upper); + /* reset back to original page */ + if (newindx < split_indx) { + mc->mc_pg[mc->mc_top] = mp; + if (nflags & MDB_RESERVE) { + node = NODEPTR(mp, mc->mc_ki[mc->mc_top]); + if (!(node->mn_flags & F_BIGDATA)) + newdata->mv_data = NODEDATA(node); + } + } + /* return tmp page to freelist */ copy->mp_next = mc->mc_txn->mt_env->me_dpages; mc->mc_txn->mt_env->me_dpages = copy;