mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-01 23:54:12 +08:00
mdbx: Add mdbx_txn_break().
Change-Id: Id38a09a0a95d092d75f2eb4fad2cbd7805cd59d0
This commit is contained in:
parent
ec7126420f
commit
1d48cb88fe
13
mdbx.h
13
mdbx.h
@ -2771,6 +2771,19 @@ LIBMDBX_API int mdbx_txn_commit(MDBX_txn *txn);
|
|||||||
* \retval MDBX_EINVAL Transaction handle is NULL. */
|
* \retval MDBX_EINVAL Transaction handle is NULL. */
|
||||||
LIBMDBX_API int mdbx_txn_abort(MDBX_txn *txn);
|
LIBMDBX_API int mdbx_txn_abort(MDBX_txn *txn);
|
||||||
|
|
||||||
|
/** Marks transaction as broken.
|
||||||
|
* \ingroup c_transactions
|
||||||
|
*
|
||||||
|
* Function keeps the transaction handle and corresponding locks, but it
|
||||||
|
* is not possible to perform any operations in a broken transaction.
|
||||||
|
* Broken transaction must then be aborted explicitly later.
|
||||||
|
*
|
||||||
|
* \param [in] txn A transaction handle returned by \ref mdbx_txn_begin().
|
||||||
|
*
|
||||||
|
* \see mdbx_txn_abort() \see mdbx_txn_reset() \see mdbx_txn_commit()
|
||||||
|
* \returns A non-zero error value on failure and 0 on success. */
|
||||||
|
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn);
|
||||||
|
|
||||||
/** Reset a read-only transaction.
|
/** Reset a read-only transaction.
|
||||||
* \ingroup c_transactions
|
* \ingroup c_transactions
|
||||||
*
|
*
|
||||||
|
13
src/core.c
13
src/core.c
@ -6850,6 +6850,19 @@ int mdbx_txn_reset(MDBX_txn *txn) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mdbx_txn_break(MDBX_txn *txn) {
|
||||||
|
do {
|
||||||
|
int rc = check_txn(txn, 0);
|
||||||
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
|
return rc;
|
||||||
|
txn->mt_flags |= MDBX_TXN_ERROR;
|
||||||
|
if (txn->mt_flags & MDBX_TXN_RDONLY)
|
||||||
|
break;
|
||||||
|
txn = txn->mt_child;
|
||||||
|
} while (txn);
|
||||||
|
return MDBX_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int mdbx_txn_abort(MDBX_txn *txn) {
|
int mdbx_txn_abort(MDBX_txn *txn) {
|
||||||
int rc = check_txn(txn, 0);
|
int rc = check_txn(txn, 0);
|
||||||
if (unlikely(rc != MDBX_SUCCESS))
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user