From 224f26813e60e371c3779ec1e8d0d987d0adbfb0 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: Wed, 11 Oct 2023 12:27:31 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20`MDBX=5FTXN=5FINVALID`=20(`INT?= =?UTF-8?q?32=5FMIN`)=20=D0=B8=D0=B7=20`mdbx=5Ftxn=5Fflags()`=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=20=D0=BD=D0=B5=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=82=D1=80=D0=B0=D0=BD=D0=B7=D0=B0=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h | 2 +- src/core.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mdbx.h b/mdbx.h index c94bde3f..84355922 100644 --- a/mdbx.h +++ b/mdbx.h @@ -3764,7 +3764,7 @@ mdbx_txn_env(const MDBX_txn *txn); * \param [in] txn A transaction handle returned by \ref mdbx_txn_begin(). * * \returns A transaction flags, valid if input is an valid transaction, - * otherwise -1. */ + * otherwise \ref MDBX_TXN_INVALID. */ MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_txn_flags(const MDBX_txn *txn); /** \brief Return the transaction's ID. diff --git a/src/core.c b/src/core.c index 380ab461..911f92ea 100644 --- a/src/core.c +++ b/src/core.c @@ -9570,10 +9570,13 @@ uint64_t mdbx_txn_id(const MDBX_txn *txn) { } int mdbx_txn_flags(const MDBX_txn *txn) { - if (unlikely(!txn || txn->mt_signature != MDBX_MT_SIGNATURE)) { - assert((-1 & (int)MDBX_TXN_INVALID) != 0); - return -1; - } + STATIC_ASSERT( + (MDBX_TXN_INVALID & + (MDBX_TXN_FINISHED | MDBX_TXN_ERROR | MDBX_TXN_DIRTY | MDBX_TXN_SPILLS | + MDBX_TXN_HAS_CHILD | MDBX_TXN_DRAINED_GC | MDBX_SHRINK_ALLOWED | + MDBX_TXN_RW_BEGIN_FLAGS | MDBX_TXN_RO_BEGIN_FLAGS)) == 0); + if (unlikely(!txn || txn->mt_signature != MDBX_MT_SIGNATURE)) + return MDBX_TXN_INVALID; assert(0 == (int)(txn->mt_flags & MDBX_TXN_INVALID)); return txn->mt_flags; }