libmdbx/test/try.cc
Leonid Yuriev ffa10a25d6 mdbx: use enums & bool in the C API.
Change-Id: I952f578cceb7d02ade16f545d47245d4d9106441
2020-08-06 01:48:56 +03:00

21 lines
526 B
C++

#include "test.h"
bool testcase_try::run() {
db_open();
assert(!txn_guard);
MDBX_txn *txn = nullptr;
MDBX_txn *txn2 = nullptr;
int rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TXN_READWRITE, &txn);
if (unlikely(rc != MDBX_SUCCESS))
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
else {
rc = mdbx_txn_begin(db_guard.get(), nullptr, MDBX_TXN_TRY, &txn2);
if (unlikely(rc != MDBX_BUSY))
failure_perror("mdbx_txn_begin(MDBX_TXN_TRY)", rc);
}
txn_guard.reset(txn);
return true;
}