Need to check NUMKEYS as well as fill threshold, when deciding
whether to change anything. Don't let the page drop below the
minimum number of keys.
unsigned int ptop, minkeys;
MDB_cursor mn;
+ minkeys = 1 + (IS_BRANCH(mc->mc_pg[mc->mc_top]));
#if MDB_DEBUG
{
pgno_t pgno;
}
#endif
- if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD) {
+ if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD &&
+ NUMKEYS(mc->mc_pg[mc->mc_top] >= minkeys)) {
#if MDB_DEBUG
pgno_t pgno;
COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);