diff --git a/src/api-txn.c b/src/api-txn.c index 5ad6f081..4a343d50 100644 --- a/src/api-txn.c +++ b/src/api-txn.c @@ -411,7 +411,7 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) { if (likely(rc == MDBX_SUCCESS)) goto done; if (rc == MDBX_RESULT_TRUE) { -#if defined(MDBX_NOSUCCESS_EMPTY_COMMIT) && MDBX_NOSUCCESS_EMPTY_COMMIT +#if MDBX_NOSUCCESS_PURE_COMMIT rc = txn_end(txn, end_mode); if (unlikely(rc != MDBX_SUCCESS)) goto fail; @@ -419,7 +419,7 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) { goto provide_latency; #else goto done; -#endif /* MDBX_NOSUCCESS_EMPTY_COMMIT */ +#endif /* MDBX_NOSUCCESS_PURE_COMMIT */ } fail: diff --git a/src/options.h b/src/options.h index 1a80cd20..f641f827 100644 --- a/src/options.h +++ b/src/options.h @@ -257,6 +257,14 @@ #error MDBX_HAVE_BUILTIN_CPU_SUPPORTS must be defined as 0 or 1 #endif /* MDBX_HAVE_BUILTIN_CPU_SUPPORTS */ +/** if enabled then treats the commit of pure (nothing changes) transactions as special + * cases and return \ref MDBX_RESULT_TRUE instead of \ref MDBX_SUCCESS. */ +#ifndef MDBX_NOSUCCESS_PURE_COMMIT +#define MDBX_NOSUCCESS_PURE_COMMIT 0 +#elif !(MDBX_NOSUCCESS_PURE_COMMIT == 0 || MDBX_NOSUCCESS_PURE_COMMIT == 1) +#error MDBX_NOSUCCESS_PURE_COMMIT must be defined as 0 or 1 +#endif /* MDBX_NOSUCCESS_PURE_COMMIT */ + //------------------------------------------------------------------------------ /** Win32 File Locking API for \ref MDBX_LOCKING */ diff --git a/src/txn.c b/src/txn.c index b98eb685..7dc2aa78 100644 --- a/src/txn.c +++ b/src/txn.c @@ -1436,7 +1436,7 @@ int txn_basal_commit(MDBX_txn *txn, struct commit_timestamp *ts) { (txn->flags & (MDBX_TXN_DIRTY | MDBX_TXN_SPILLS)) == 0) { TXN_FOREACH_DBI_ALL(txn, i) { tASSERT(txn, !(txn->dbi_state[i] & DBI_DIRTY)); } /* fast completion of pure transaction */ - return MDBX_RESULT_TRUE; + return MDBX_NOSUCCESS_PURE_COMMIT ? MDBX_RESULT_TRUE : MDBX_SUCCESS; } DEBUG("committing txn %" PRIaTXN " %p on env %p, root page %" PRIaPGNO "/%" PRIaPGNO, txn->txnid, (void *)txn,