mdbx: оформление опции сборки MDBX_NOSUCCESS_PURE_COMMIT (выключено по умолчанию).

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2025-01-10 12:07:48 +03:00
parent c60f6afe5f
commit 6d92a778a5
3 changed files with 11 additions and 3 deletions

View File

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

View File

@ -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 */

View File

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