From bfea3ca9fb7e2a3078746ee16ab600fa1b15e367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sat, 19 Feb 2022 13:18:03 +0300 Subject: [PATCH] mdbx: minor refine `mdbx_page_search()` internals. --- src/core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core.c b/src/core.c index 4ce06ee0..86784f5a 100644 --- a/src/core.c +++ b/src/core.c @@ -13682,15 +13682,17 @@ __hot static int mdbx_page_search(MDBX_cursor *mc, const MDBX_val *key, pp_txnid = /* mc->mc_db->md_mod_txnid maybe zero in a legacy DB */ pp_txnid ? pp_txnid : mc->mc_txn->mt_txnid; - MDBX_txn *scan = mc->mc_txn; - do - if ((scan->mt_flags & MDBX_TXN_DIRTY) && - (mc->mc_dbi == MAIN_DBI || - (scan->mt_dbistate[mc->mc_dbi] & DBI_DIRTY))) { - pp_txnid = scan->mt_front; - break; - } - while (unlikely((scan = scan->mt_parent) != nullptr)); + if ((mc->mc_txn->mt_flags & MDBX_TXN_RDONLY) == 0) { + MDBX_txn *scan = mc->mc_txn; + do + if ((scan->mt_flags & MDBX_TXN_DIRTY) && + (mc->mc_dbi == MAIN_DBI || + (scan->mt_dbistate[mc->mc_dbi] & DBI_DIRTY))) { + pp_txnid = scan->mt_front; + break; + } + while (unlikely((scan = scan->mt_parent) != nullptr)); + } if (unlikely((rc = mdbx_page_get(mc, root, &mc->mc_pg[0], pp_txnid)) != 0)) return rc; }