/* Adjust other cursors pointing to mp */
for (m2 = mc->mc_txn->mt_cursors[dbi]; m2; m2=m2->mc_next) {
- if (m2 == mc)
+ if (m2 == mc || m2->mc_snum < mc->mc_snum)
continue;
if (!(m2->mc_flags & C_INITIALIZED))
continue;
psize = 0;
if (newindx <= split_indx || newindx >= nkeys) {
i = 0; j = 1;
- k = newindx >= nkeys ? nkeys : split_indx+1;
+ k = newindx >= nkeys ? nkeys : split_indx+2;
} else {
i = nkeys; j = -1;
k = split_indx-1;
}
psize += psize & 1;
}
- if (psize > pmax) {
+ if (psize > pmax || i == k-j) {
split_indx = i + (j<0);
break;
}
}
- /* special case: when the new node was on the last
- * slot we may not have tripped the break inside the loop.
- * In all other cases we either hit the break condition,
- * or the original split_indx was already safe.
- */
- if (newindx >= nkeys && i == k)
- split_indx = nkeys-1;
}
if (split_indx == newindx) {
sepkey.mv_size = newkey->mv_size;