From a2ec7f2be1ddfb04a9e7eeb4aa1f28b69a4a961d Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 19 Mar 2018 17:03:41 +0300 Subject: [PATCH] mdbx: add mdbx_txn_flags(). --- mdbx.h | 9 +++++++++ src/mdbx.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/mdbx.h b/mdbx.h index df168eea..36146fb6 100644 --- a/mdbx.h +++ b/mdbx.h @@ -982,6 +982,15 @@ LIBMDBX_API int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags, * [in] txn A transaction handle returned by mdbx_txn_begin() */ LIBMDBX_API MDBX_env *mdbx_txn_env(MDBX_txn *txn); +/* Return the transaction's flags. + * + * This returns the flags associated with this transaction. + * + * [in] txn A transaction handle returned by mdbx_txn_begin() + * + * Returns A transaction flags, valid if input is an active transaction. */ +LIBMDBX_API int mdbx_txn_flags(MDBX_txn *txn); + /* Return the transaction's ID. * * This returns the identifier associated with this transaction. For a diff --git a/src/mdbx.c b/src/mdbx.c index faa1541d..bbced7d4 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -2987,6 +2987,13 @@ uint64_t mdbx_txn_id(MDBX_txn *txn) { return txn->mt_txnid; } +int mdbx_txn_flags(MDBX_txn *txn) { + if (unlikely(!txn || txn->mt_signature != MDBX_MT_SIGNATURE)) + return -1; + + return txn->mt_flags; +} + /* Export or close DBI handles opened in this txn. */ static void mdbx_dbis_update(MDBX_txn *txn, int keep) { MDBX_dbi n = txn->mt_numdbs;