mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-08 04:54:13 +08:00
mdbx: minor simplify page_get()
.
Change-Id: I2a548ea008fad29da8382946dff3c7d9bffa1e85
This commit is contained in:
parent
d78150de79
commit
0cc695e22e
10
src/core.c
10
src/core.c
@ -12452,20 +12452,18 @@ __hot static int mdbx_page_get(MDBX_cursor *mc, pgno_t pgno, MDBX_page **ret,
|
|||||||
MDBX_txn *txn = mc->mc_txn;
|
MDBX_txn *txn = mc->mc_txn;
|
||||||
if (unlikely(pgno >= txn->mt_next_pgno)) {
|
if (unlikely(pgno >= txn->mt_next_pgno)) {
|
||||||
mdbx_error("page #%" PRIaPGNO " beyond next-pgno", pgno);
|
mdbx_error("page #%" PRIaPGNO " beyond next-pgno", pgno);
|
||||||
notfound:
|
|
||||||
*ret = nullptr;
|
*ret = nullptr;
|
||||||
txn->mt_flags |= MDBX_TXN_ERROR;
|
goto corrupted;
|
||||||
return MDBX_PAGE_NOTFOUND;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MDBX_env *const env = txn->mt_env;
|
MDBX_env *const env = txn->mt_env;
|
||||||
MDBX_page *p = nullptr;
|
|
||||||
mdbx_assert(env, ((txn->mt_flags ^ env->me_flags) & MDBX_WRITEMAP) == 0);
|
mdbx_assert(env, ((txn->mt_flags ^ env->me_flags) & MDBX_WRITEMAP) == 0);
|
||||||
mdbx_assert(env, pp_txnid >= MIN_TXNID && pp_txnid <= txn->mt_txnid);
|
mdbx_assert(env, pp_txnid >= MIN_TXNID && pp_txnid <= txn->mt_txnid);
|
||||||
const uint16_t illegal_bits =
|
const uint16_t illegal_bits =
|
||||||
(txn->mt_flags & MDBX_TXN_RDONLY)
|
(txn->mt_flags & MDBX_TXN_RDONLY)
|
||||||
? ~(P_BRANCH | P_LEAF | P_LEAF2 | P_OVERFLOW)
|
? ~(P_BRANCH | P_LEAF | P_LEAF2 | P_OVERFLOW)
|
||||||
: ~(P_BRANCH | P_LEAF | P_LEAF2 | P_OVERFLOW | P_DIRTY);
|
: ~(P_BRANCH | P_LEAF | P_LEAF2 | P_OVERFLOW | P_DIRTY);
|
||||||
|
MDBX_page *p;
|
||||||
int level;
|
int level;
|
||||||
if (unlikely((txn->mt_flags & (MDBX_TXN_RDONLY | MDBX_WRITEMAP)) == 0)) {
|
if (unlikely((txn->mt_flags & (MDBX_TXN_RDONLY | MDBX_WRITEMAP)) == 0)) {
|
||||||
level = 1;
|
level = 1;
|
||||||
@ -12498,7 +12496,7 @@ dirty:
|
|||||||
bad_page(
|
bad_page(
|
||||||
p, "mismatch actual pgno (%" PRIaPGNO ") != expected (%" PRIaPGNO ")\n",
|
p, "mismatch actual pgno (%" PRIaPGNO ") != expected (%" PRIaPGNO ")\n",
|
||||||
p->mp_pgno, pgno);
|
p->mp_pgno, pgno);
|
||||||
goto notfound;
|
goto corrupted;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(p->mp_flags & illegal_bits)) {
|
if (unlikely(p->mp_flags & illegal_bits)) {
|
||||||
@ -12529,7 +12527,7 @@ dirty:
|
|||||||
|
|
||||||
corrupted:
|
corrupted:
|
||||||
mc->mc_txn->mt_flags |= MDBX_TXN_ERROR;
|
mc->mc_txn->mt_flags |= MDBX_TXN_ERROR;
|
||||||
return MDBX_CORRUPTED;
|
return MDBX_PAGE_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish mdbx_page_search() / mdbx_page_search_lowest().
|
/* Finish mdbx_page_search() / mdbx_page_search_lowest().
|
||||||
|
Loading…
x
Reference in New Issue
Block a user