mdbx: move most of transactions flags to public API.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev)
2022-05-02 10:35:40 +03:00
parent 34e8467409
commit 838f8d8fab
3 changed files with 46 additions and 16 deletions

View File

@@ -8434,8 +8434,11 @@ 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))
if (unlikely(!txn || txn->mt_signature != MDBX_MT_SIGNATURE)) {
assert((-1 & (int)MDBX_TXN_INVALID) != 0);
return -1;
}
assert(0 == (int)(txn->mt_flags & MDBX_TXN_INVALID));
return txn->mt_flags;
}

View File

@@ -895,16 +895,6 @@ struct MDBX_txn {
/* Additional flag for mdbx_sync_locked() */
#define MDBX_SHRINK_ALLOWED UINT32_C(0x40000000)
/* internal txn flags */
#define MDBX_TXN_FINISHED 0x01 /* txn is finished or never began */
#define MDBX_TXN_ERROR 0x02 /* txn is unusable after an error */
#define MDBX_TXN_DIRTY 0x04 /* must write, even if dirty list is empty */
#define MDBX_TXN_SPILLS 0x08 /* txn or a parent has spilled pages */
#define MDBX_TXN_HAS_CHILD 0x10 /* txn has an MDBX_txn.mt_child */
/* most operations on the txn are currently illegal */
#define MDBX_TXN_BLOCKED \
(MDBX_TXN_FINISHED | MDBX_TXN_ERROR | MDBX_TXN_HAS_CHILD)
#define TXN_FLAGS \
(MDBX_TXN_FINISHED | MDBX_TXN_ERROR | MDBX_TXN_DIRTY | MDBX_TXN_SPILLS | \
MDBX_TXN_HAS_CHILD)
@@ -912,7 +902,7 @@ struct MDBX_txn {
#if (TXN_FLAGS & (MDBX_TXN_RW_BEGIN_FLAGS | MDBX_TXN_RO_BEGIN_FLAGS)) || \
((MDBX_TXN_RW_BEGIN_FLAGS | MDBX_TXN_RO_BEGIN_FLAGS | TXN_FLAGS) & \
MDBX_SHRINK_ALLOWED)
#error "Oops, some flags overlapped or wrong"
#error "Oops, some txn flags overlapped or wrong"
#endif
uint32_t mt_flags;