mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-testing: добавление mdbx_txn_copy2pathname()
в тестовый сценарий.
This commit is contained in:
parent
e7488bc30c
commit
4c0290b576
8
mdbx.h
8
mdbx.h
@ -1719,16 +1719,16 @@ typedef enum MDBX_copy_flags {
|
|||||||
MDBX_CP_DONT_FLUSH = 4u,
|
MDBX_CP_DONT_FLUSH = 4u,
|
||||||
|
|
||||||
/** Use read transaction parking during copying MVCC-snapshot
|
/** Use read transaction parking during copying MVCC-snapshot
|
||||||
* \see mdbx_txn_park() */
|
* \see mdbx_txn_park() */
|
||||||
MDBX_CP_THROTTLE_MVCC = 8u,
|
MDBX_CP_THROTTLE_MVCC = 8u,
|
||||||
|
|
||||||
/** Abort/dispose passed transaction after copy
|
/** Abort/dispose passed transaction after copy
|
||||||
* \see mdbx_txn_copy2fd() \see mdbx_txn_copy2pathname() */
|
* \see mdbx_txn_copy2fd() \see mdbx_txn_copy2pathname() */
|
||||||
MDBX_CP_DISPOSE_TXN = 16u,
|
MDBX_CP_DISPOSE_TXN = 16u,
|
||||||
|
|
||||||
/** Enable renew/restart read transaction in case it use outdated
|
/** Enable renew/restart read transaction in case it use outdated
|
||||||
* MVCC shapshot, otherwise the \ref MDBX_MVCC_RETARDED will be returned
|
* MVCC shapshot, otherwise the \ref MDBX_MVCC_RETARDED will be returned
|
||||||
* \see mdbx_txn_copy2fd() \see mdbx_txn_copy2pathname() */
|
* \see mdbx_txn_copy2fd() \see mdbx_txn_copy2pathname() */
|
||||||
MDBX_CP_RENEW_TXN = 32u
|
MDBX_CP_RENEW_TXN = 32u
|
||||||
|
|
||||||
} MDBX_copy_flags_t;
|
} MDBX_copy_flags_t;
|
||||||
|
@ -20,12 +20,34 @@ void testcase_copy::copy_db(const bool with_compaction) {
|
|||||||
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
|
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
|
||||||
failure_perror("osal_removefile()", err);
|
failure_perror("osal_removefile()", err);
|
||||||
|
|
||||||
err = mdbx_env_copy(db_guard.get(), copy_pathname.c_str(),
|
if (flipcoin()) {
|
||||||
with_compaction ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS);
|
err = mdbx_env_copy(db_guard.get(), copy_pathname.c_str(),
|
||||||
if (unlikely(err != MDBX_SUCCESS))
|
with_compaction ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS);
|
||||||
failure_perror(with_compaction ? "mdbx_env_copy(MDBX_CP_COMPACT)"
|
if (unlikely(err != MDBX_SUCCESS))
|
||||||
: "mdbx_env_copy(MDBX_CP_ASIS)",
|
failure_perror(with_compaction ? "mdbx_env_copy(MDBX_CP_COMPACT)"
|
||||||
err);
|
: "mdbx_env_copy(MDBX_CP_ASIS)",
|
||||||
|
err);
|
||||||
|
} else {
|
||||||
|
const bool ro = mode_readonly() || flipcoin();
|
||||||
|
const bool throttle = ro && flipcoin();
|
||||||
|
const bool dynsize = flipcoin();
|
||||||
|
const bool flush = flipcoin();
|
||||||
|
const bool enable_renew = flipcoin();
|
||||||
|
const MDBX_copy_flags_t flags =
|
||||||
|
(with_compaction ? MDBX_CP_COMPACT : MDBX_CP_DEFAULTS) |
|
||||||
|
(dynsize ? MDBX_CP_FORCE_DYNAMIC_SIZE : MDBX_CP_DEFAULTS) |
|
||||||
|
(throttle ? MDBX_CP_THROTTLE_MVCC : MDBX_CP_DEFAULTS) |
|
||||||
|
(flush ? MDBX_CP_DEFAULTS : MDBX_CP_DONT_FLUSH) |
|
||||||
|
(enable_renew ? MDBX_CP_RENEW_TXN : MDBX_CP_DEFAULTS);
|
||||||
|
txn_begin(ro);
|
||||||
|
err = mdbx_txn_copy2pathname(txn_guard.get(), copy_pathname.c_str(), flags);
|
||||||
|
if (unlikely(err != MDBX_SUCCESS && (!throttle || err != MDBX_OUSTED) &&
|
||||||
|
(!enable_renew && err != MDBX_MVCC_RETARDED)))
|
||||||
|
failure_perror(with_compaction ? "mdbx_txn_copy2pathname(MDBX_CP_COMPACT)"
|
||||||
|
: "mdbx_txn_copy2pathname(MDBX_CP_ASIS)",
|
||||||
|
err);
|
||||||
|
txn_end(err != MDBX_SUCCESS || flipcoin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool testcase_copy::run() {
|
bool testcase_copy::run() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user