]> git.sur5r.net Git - openldap/commitdiff
Fix page_split with MDB_RESERVE
authorHoward Chu <hyc@openldap.org>
Fri, 7 Oct 2011 01:53:07 +0000 (18:53 -0700)
committerHoward Chu <hyc@openldap.org>
Fri, 7 Oct 2011 01:53:07 +0000 (18:53 -0700)
libraries/libmdb/mdb.c

index dc333e91ab2bc316b46fec485ebf9bf2b3376291..5ef3022b074d586dd5181de93f86353856b69b0b 100644 (file)
@@ -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; i<nkeys; i++)
                mp->mp_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;