mdbx: возвращение MDBX_TXN_INVALID (INT32_MIN) из mdbx_txn_flags() при передаче невалидной транзакции.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2023-10-11 12:27:31 +03:00
parent fc1685a178
commit 224f26813e
2 changed files with 8 additions and 5 deletions

2
mdbx.h
View File

@ -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.

View File

@ -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;
}