mdbx: refine mdbx_page_new().

Change-Id: Ief0cb313c39f7b11fb1cd611d9b0497c011a7a7a
This commit is contained in:
Leonid Yuriev 2021-04-11 19:08:33 +03:00
parent 49296cad14
commit e35c92eabb

View File

@ -14796,21 +14796,23 @@ static int mdbx_page_new(MDBX_cursor *mc, unsigned flags, unsigned num,
np->mp_pgno, num);
np->mp_flags = (uint16_t)(flags | P_DIRTY);
np->mp_txnid = INVALID_TXNID;
np->mp_lower = 0;
np->mp_upper = (indx_t)(mc->mc_txn->mt_env->me_psize - PAGEHDRSZ);
*mc->mc_dbistate |= DBI_DIRTY;
mc->mc_txn->mt_flags |= MDBX_TXN_DIRTY;
mc->mc_db->md_branch_pages += IS_BRANCH(np);
mc->mc_db->md_leaf_pages += IS_LEAF(np);
if (unlikely(IS_OVERFLOW(np))) {
if (likely(!IS_OVERFLOW(np))) {
np->mp_lower = 0;
np->mp_upper = (indx_t)(mc->mc_txn->mt_env->me_psize - PAGEHDRSZ);
mc->mc_db->md_branch_pages += IS_BRANCH(np);
mc->mc_db->md_leaf_pages += IS_LEAF(np);
if (unlikely(mc->mc_flags & C_SUB)) {
MDBX_db *outer = mdbx_outer_db(mc);
outer->md_branch_pages += IS_BRANCH(np);
outer->md_leaf_pages += IS_LEAF(np);
}
} else {
mc->mc_db->md_overflow_pages += num;
np->mp_pages = num;
mdbx_cassert(mc, !(mc->mc_flags & C_SUB));
} else if (unlikely(mc->mc_flags & C_SUB)) {
MDBX_db *outer = mdbx_outer_db(mc);
outer->md_branch_pages += IS_BRANCH(np);
outer->md_leaf_pages += IS_LEAF(np);
}
return MDBX_SUCCESS;