mirror of
https://gitflic.ru/project/erthink/libmdbx.git
synced 2025-06-21 15:28:52 +00:00
mdbx++: расширение API методами принимающими имена subDb через mdbx::slice
.
This commit is contained in:
parent
69df6e6ac0
commit
49c6e14b30
166
mdbx.h++
166
mdbx.h++
@ -4384,11 +4384,18 @@ public:
|
|||||||
const ::std::string &name,
|
const ::std::string &name,
|
||||||
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const;
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const;
|
||||||
|
/// \brief Open existing key-value map.
|
||||||
|
inline map_handle open_map(
|
||||||
|
const ::mdbx::slice &name,
|
||||||
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const;
|
||||||
|
|
||||||
/// \brief Open existing key-value map.
|
/// \brief Open existing key-value map.
|
||||||
inline map_handle open_map_accede(const char *name) const;
|
inline map_handle open_map_accede(const char *name) const;
|
||||||
/// \brief Open existing key-value map.
|
/// \brief Open existing key-value map.
|
||||||
inline map_handle open_map_accede(const ::std::string &name) const;
|
inline map_handle open_map_accede(const ::std::string &name) const;
|
||||||
|
/// \brief Open existing key-value map.
|
||||||
|
inline map_handle open_map_accede(const ::mdbx::slice &name) const;
|
||||||
|
|
||||||
/// \brief Create new or open existing key-value map.
|
/// \brief Create new or open existing key-value map.
|
||||||
inline map_handle
|
inline map_handle
|
||||||
@ -4400,6 +4407,11 @@ public:
|
|||||||
create_map(const ::std::string &name,
|
create_map(const ::std::string &name,
|
||||||
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single);
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single);
|
||||||
|
/// \brief Create new or open existing key-value map.
|
||||||
|
inline map_handle
|
||||||
|
create_map(const ::mdbx::slice &name,
|
||||||
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single);
|
||||||
|
|
||||||
/// \brief Drops key-value map using handle.
|
/// \brief Drops key-value map using handle.
|
||||||
inline void drop_map(map_handle map);
|
inline void drop_map(map_handle map);
|
||||||
@ -4411,6 +4423,10 @@ public:
|
|||||||
/// \return `True` if the key-value map existed and was deleted, either
|
/// \return `True` if the key-value map existed and was deleted, either
|
||||||
/// `false` if the key-value map did not exist and there is nothing to delete.
|
/// `false` if the key-value map did not exist and there is nothing to delete.
|
||||||
inline bool drop_map(const ::std::string &name, bool throw_if_absent = false);
|
inline bool drop_map(const ::std::string &name, bool throw_if_absent = false);
|
||||||
|
/// \brief Drop key-value map.
|
||||||
|
/// \return `True` if the key-value map existed and was deleted, either
|
||||||
|
/// `false` if the key-value map did not exist and there is nothing to delete.
|
||||||
|
bool drop_map(const ::mdbx::slice &name, bool throw_if_absent = false);
|
||||||
|
|
||||||
/// \brief Clear key-value map.
|
/// \brief Clear key-value map.
|
||||||
inline void clear_map(map_handle map);
|
inline void clear_map(map_handle map);
|
||||||
@ -4421,12 +4437,17 @@ public:
|
|||||||
/// `false` if the key-value map did not exist and there is nothing to clear.
|
/// `false` if the key-value map did not exist and there is nothing to clear.
|
||||||
inline bool clear_map(const ::std::string &name,
|
inline bool clear_map(const ::std::string &name,
|
||||||
bool throw_if_absent = false);
|
bool throw_if_absent = false);
|
||||||
|
/// \return `True` if the key-value map existed and was cleared, either
|
||||||
|
/// `false` if the key-value map did not exist and there is nothing to clear.
|
||||||
|
bool clear_map(const ::mdbx::slice &name, bool throw_if_absent = false);
|
||||||
|
|
||||||
/// \brief Переименовывает таблицу ключ-значение.
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
inline void rename_map(map_handle map, const char *new_name);
|
inline void rename_map(map_handle map, const char *new_name);
|
||||||
/// \brief Переименовывает таблицу ключ-значение.
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
inline void rename_map(map_handle map, const ::std::string &new_name);
|
inline void rename_map(map_handle map, const ::std::string &new_name);
|
||||||
/// \brief Переименовывает таблицу ключ-значение.
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
|
inline void rename_map(map_handle map, const ::mdbx::slice &new_name);
|
||||||
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
/// \return `True` если таблица существует и была переименована, либо
|
/// \return `True` если таблица существует и была переименована, либо
|
||||||
/// `false` в случае отсутствия исходной таблицы.
|
/// `false` в случае отсутствия исходной таблицы.
|
||||||
bool rename_map(const char *old_name, const char *new_name,
|
bool rename_map(const char *old_name, const char *new_name,
|
||||||
@ -4436,6 +4457,11 @@ public:
|
|||||||
/// `false` в случае отсутствия исходной таблицы.
|
/// `false` в случае отсутствия исходной таблицы.
|
||||||
bool rename_map(const ::std::string &old_name, const ::std::string &new_name,
|
bool rename_map(const ::std::string &old_name, const ::std::string &new_name,
|
||||||
bool throw_if_absent = false);
|
bool throw_if_absent = false);
|
||||||
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
|
/// \return `True` если таблица существует и была переименована, либо
|
||||||
|
/// `false` в случае отсутствия исходной таблицы.
|
||||||
|
bool rename_map(const ::mdbx::slice &old_name, const ::mdbx::slice &new_name,
|
||||||
|
bool throw_if_absent = false);
|
||||||
|
|
||||||
#if defined(DOXYGEN) || \
|
#if defined(DOXYGEN) || \
|
||||||
(defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
|
(defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
|
||||||
@ -4444,21 +4470,29 @@ public:
|
|||||||
inline map_handle open_map(
|
inline map_handle open_map(
|
||||||
const ::std::string_view &name,
|
const ::std::string_view &name,
|
||||||
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const;
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const {
|
||||||
|
return open_map(::mdbx::slice(name), key_mode, value_mode);
|
||||||
|
}
|
||||||
/// \brief Open existing key-value map.
|
/// \brief Open existing key-value map.
|
||||||
inline map_handle open_map_accede(const ::std::string_view &name) const;
|
inline map_handle open_map_accede(const ::std::string_view &name) const;
|
||||||
/// \brief Create new or open existing key-value map.
|
/// \brief Create new or open existing key-value map.
|
||||||
inline map_handle
|
inline map_handle
|
||||||
create_map(const ::std::string_view &name,
|
create_map(const ::std::string_view &name,
|
||||||
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual,
|
||||||
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single);
|
const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) {
|
||||||
|
return create_map(::mdbx::slice(name), key_mode, value_mode);
|
||||||
|
}
|
||||||
/// \brief Drop key-value map.
|
/// \brief Drop key-value map.
|
||||||
/// \return `True` if the key-value map existed and was deleted, either
|
/// \return `True` if the key-value map existed and was deleted, either
|
||||||
/// `false` if the key-value map did not exist and there is nothing to delete.
|
/// `false` if the key-value map did not exist and there is nothing to delete.
|
||||||
bool drop_map(const ::std::string_view &name, bool throw_if_absent = false);
|
bool drop_map(const ::std::string_view &name, bool throw_if_absent = false) {
|
||||||
|
return drop_map(::mdbx::slice(name), throw_if_absent);
|
||||||
|
}
|
||||||
/// \return `True` if the key-value map existed and was cleared, either
|
/// \return `True` if the key-value map existed and was cleared, either
|
||||||
/// `false` if the key-value map did not exist and there is nothing to clear.
|
/// `false` if the key-value map did not exist and there is nothing to clear.
|
||||||
bool clear_map(const ::std::string_view &name, bool throw_if_absent = false);
|
bool clear_map(const ::std::string_view &name, bool throw_if_absent = false) {
|
||||||
|
return clear_map(::mdbx::slice(name), throw_if_absent);
|
||||||
|
}
|
||||||
/// \brief Переименовывает таблицу ключ-значение.
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
inline void rename_map(map_handle map, const ::std::string_view &new_name);
|
inline void rename_map(map_handle map, const ::std::string_view &new_name);
|
||||||
/// \brief Переименовывает таблицу ключ-значение.
|
/// \brief Переименовывает таблицу ключ-значение.
|
||||||
@ -4466,8 +4500,10 @@ public:
|
|||||||
/// `false` в случае отсутствия исходной таблицы.
|
/// `false` в случае отсутствия исходной таблицы.
|
||||||
bool rename_map(const ::std::string_view &old_name,
|
bool rename_map(const ::std::string_view &old_name,
|
||||||
const ::std::string_view &new_name,
|
const ::std::string_view &new_name,
|
||||||
bool throw_if_absent = false);
|
bool throw_if_absent = false) {
|
||||||
|
return rename_map(::mdbx::slice(old_name), ::mdbx::slice(new_name),
|
||||||
|
throw_if_absent);
|
||||||
|
}
|
||||||
#endif /* __cpp_lib_string_view >= 201606L */
|
#endif /* __cpp_lib_string_view >= 201606L */
|
||||||
|
|
||||||
using map_stat = ::MDBX_stat;
|
using map_stat = ::MDBX_stat;
|
||||||
@ -6427,6 +6463,17 @@ inline size_t txn::release_all_cursors(bool unbind) const {
|
|||||||
return size_t(err);
|
return size_t(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ::mdbx::map_handle
|
||||||
|
txn::open_map(const ::mdbx::slice &name, const ::mdbx::key_mode key_mode,
|
||||||
|
const ::mdbx::value_mode value_mode) const {
|
||||||
|
::mdbx::map_handle map;
|
||||||
|
error::success_or_throw(::mdbx_dbi_open2(
|
||||||
|
handle_, name, MDBX_db_flags_t(key_mode) | MDBX_db_flags_t(value_mode),
|
||||||
|
&map.dbi));
|
||||||
|
assert(map.dbi != 0);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
inline ::mdbx::map_handle
|
||||||
txn::open_map(const char *name, const ::mdbx::key_mode key_mode,
|
txn::open_map(const char *name, const ::mdbx::key_mode key_mode,
|
||||||
const ::mdbx::value_mode value_mode) const {
|
const ::mdbx::value_mode value_mode) const {
|
||||||
@ -6438,6 +6485,15 @@ txn::open_map(const char *name, const ::mdbx::key_mode key_mode,
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ::mdbx::map_handle
|
||||||
|
txn::open_map_accede(const ::mdbx::slice &name) const {
|
||||||
|
::mdbx::map_handle map;
|
||||||
|
error::success_or_throw(
|
||||||
|
::mdbx_dbi_open2(handle_, name, MDBX_DB_ACCEDE, &map.dbi));
|
||||||
|
assert(map.dbi != 0);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle txn::open_map_accede(const char *name) const {
|
inline ::mdbx::map_handle txn::open_map_accede(const char *name) const {
|
||||||
::mdbx::map_handle map;
|
::mdbx::map_handle map;
|
||||||
error::success_or_throw(
|
error::success_or_throw(
|
||||||
@ -6446,6 +6502,18 @@ inline ::mdbx::map_handle txn::open_map_accede(const char *name) const {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ::mdbx::map_handle txn::create_map(const ::mdbx::slice &name,
|
||||||
|
const ::mdbx::key_mode key_mode,
|
||||||
|
const ::mdbx::value_mode value_mode) {
|
||||||
|
::mdbx::map_handle map;
|
||||||
|
error::success_or_throw(::mdbx_dbi_open2(
|
||||||
|
handle_, name,
|
||||||
|
MDBX_CREATE | MDBX_db_flags_t(key_mode) | MDBX_db_flags_t(value_mode),
|
||||||
|
&map.dbi));
|
||||||
|
assert(map.dbi != 0);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle txn::create_map(const char *name,
|
inline ::mdbx::map_handle txn::create_map(const char *name,
|
||||||
const ::mdbx::key_mode key_mode,
|
const ::mdbx::key_mode key_mode,
|
||||||
const ::mdbx::value_mode value_mode) {
|
const ::mdbx::value_mode value_mode) {
|
||||||
@ -6470,109 +6538,39 @@ inline void txn::rename_map(map_handle map, const char *new_name) {
|
|||||||
error::success_or_throw(::mdbx_dbi_rename(handle_, map, new_name));
|
error::success_or_throw(::mdbx_dbi_rename(handle_, map, new_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DOXYGEN) || \
|
inline void txn::rename_map(map_handle map, const ::mdbx::slice &new_name) {
|
||||||
(defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
|
error::success_or_throw(::mdbx_dbi_rename2(handle_, map, new_name));
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
|
||||||
txn::open_map(const ::std::string_view &name, const ::mdbx::key_mode key_mode,
|
|
||||||
const ::mdbx::value_mode value_mode) const {
|
|
||||||
::mdbx::map_handle map;
|
|
||||||
error::success_or_throw(::mdbx_dbi_open2(
|
|
||||||
handle_, ::mdbx::slice(name),
|
|
||||||
MDBX_db_flags_t(key_mode) | MDBX_db_flags_t(value_mode), &map.dbi));
|
|
||||||
assert(map.dbi != 0);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
|
||||||
txn::open_map_accede(const ::std::string_view &name) const {
|
|
||||||
::mdbx::map_handle map;
|
|
||||||
error::success_or_throw(
|
|
||||||
::mdbx_dbi_open2(handle_, ::mdbx::slice(name), MDBX_DB_ACCEDE, &map.dbi));
|
|
||||||
assert(map.dbi != 0);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::mdbx::map_handle txn::create_map(const ::std::string_view &name,
|
|
||||||
const ::mdbx::key_mode key_mode,
|
|
||||||
const ::mdbx::value_mode value_mode) {
|
|
||||||
::mdbx::map_handle map;
|
|
||||||
error::success_or_throw(::mdbx_dbi_open2(
|
|
||||||
handle_, ::mdbx::slice(name),
|
|
||||||
MDBX_CREATE | MDBX_db_flags_t(key_mode) | MDBX_db_flags_t(value_mode),
|
|
||||||
&map.dbi));
|
|
||||||
assert(map.dbi != 0);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void txn::rename_map(map_handle map,
|
|
||||||
const ::std::string_view &new_name) {
|
|
||||||
error::success_or_throw(
|
|
||||||
::mdbx_dbi_rename2(handle_, map, ::mdbx::slice(new_name)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
inline ::mdbx::map_handle
|
||||||
txn::open_map(const ::std::string &name, const ::mdbx::key_mode key_mode,
|
txn::open_map(const ::std::string &name, const ::mdbx::key_mode key_mode,
|
||||||
const ::mdbx::value_mode value_mode) const {
|
const ::mdbx::value_mode value_mode) const {
|
||||||
return open_map(::std::string_view(name), key_mode, value_mode);
|
return open_map(::mdbx::slice(name), key_mode, value_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
inline ::mdbx::map_handle
|
||||||
txn::open_map_accede(const ::std::string &name) const {
|
txn::open_map_accede(const ::std::string &name) const {
|
||||||
return open_map_accede(::std::string_view(name));
|
return open_map_accede(::mdbx::slice(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::mdbx::map_handle txn::create_map(const ::std::string &name,
|
inline ::mdbx::map_handle txn::create_map(const ::std::string &name,
|
||||||
const ::mdbx::key_mode key_mode,
|
const ::mdbx::key_mode key_mode,
|
||||||
const ::mdbx::value_mode value_mode) {
|
const ::mdbx::value_mode value_mode) {
|
||||||
return create_map(::std::string_view(name), key_mode, value_mode);
|
return create_map(::mdbx::slice(name), key_mode, value_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool txn::drop_map(const ::std::string &name, bool throw_if_absent) {
|
inline bool txn::drop_map(const ::std::string &name, bool throw_if_absent) {
|
||||||
return drop_map(::std::string_view(name), throw_if_absent);
|
return drop_map(::mdbx::slice(name), throw_if_absent);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool txn::clear_map(const ::std::string &name, bool throw_if_absent) {
|
inline bool txn::clear_map(const ::std::string &name, bool throw_if_absent) {
|
||||||
return clear_map(::std::string_view(name), throw_if_absent);
|
return clear_map(::mdbx::slice(name), throw_if_absent);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void txn::rename_map(map_handle map, const ::std::string &new_name) {
|
inline void txn::rename_map(map_handle map, const ::std::string &new_name) {
|
||||||
return rename_map(map, ::std::string_view(new_name));
|
return rename_map(map, ::mdbx::slice(new_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
|
||||||
txn::open_map(const ::std::string &name, const ::mdbx::key_mode key_mode,
|
|
||||||
const ::mdbx::value_mode value_mode) const {
|
|
||||||
return open_map(name.c_str(), key_mode, value_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::mdbx::map_handle
|
|
||||||
txn::open_map_accede(const ::std::string &name) const {
|
|
||||||
return open_map_accede(name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ::mdbx::map_handle txn::create_map(const ::std::string &name,
|
|
||||||
const ::mdbx::key_mode key_mode,
|
|
||||||
const ::mdbx::value_mode value_mode) {
|
|
||||||
return create_map(name.c_str(), key_mode, value_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool txn::drop_map(const ::std::string &name, bool throw_if_absent) {
|
|
||||||
return drop_map(name.c_str(), throw_if_absent);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool txn::clear_map(const ::std::string &name, bool throw_if_absent) {
|
|
||||||
return clear_map(name.c_str(), throw_if_absent);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void txn::rename_map(map_handle map, const ::std::string &new_name) {
|
|
||||||
return rename_map(map, new_name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __cpp_lib_string_view >= 201606L */
|
|
||||||
|
|
||||||
inline txn::map_stat txn::get_map_stat(map_handle map) const {
|
inline txn::map_stat txn::get_map_stat(map_handle map) const {
|
||||||
txn::map_stat r;
|
txn::map_stat r;
|
||||||
error::success_or_throw(::mdbx_dbi_stat(handle_, map.dbi, &r, sizeof(r)));
|
error::success_or_throw(::mdbx_dbi_stat(handle_, map.dbi, &r, sizeof(r)));
|
||||||
|
33
src/mdbx.c++
33
src/mdbx.c++
@ -1618,13 +1618,9 @@ __cold bool txn::rename_map(const char *old_name, const char *new_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
|
__cold bool txn::drop_map(const ::mdbx::slice &name, bool throw_if_absent) {
|
||||||
|
|
||||||
__cold bool txn::drop_map(const ::std::string_view &name,
|
|
||||||
bool throw_if_absent) {
|
|
||||||
map_handle map;
|
map_handle map;
|
||||||
const int err =
|
const int err = ::mdbx_dbi_open2(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
|
||||||
::mdbx_dbi_open2(handle_, mdbx::slice(name), MDBX_DB_ACCEDE, &map.dbi);
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case MDBX_SUCCESS:
|
case MDBX_SUCCESS:
|
||||||
drop_map(map);
|
drop_map(map);
|
||||||
@ -1639,11 +1635,9 @@ __cold bool txn::drop_map(const ::std::string_view &name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__cold bool txn::clear_map(const ::std::string_view &name,
|
__cold bool txn::clear_map(const ::mdbx::slice &name, bool throw_if_absent) {
|
||||||
bool throw_if_absent) {
|
|
||||||
map_handle map;
|
map_handle map;
|
||||||
const int err =
|
const int err = ::mdbx_dbi_open2(handle_, name, MDBX_DB_ACCEDE, &map.dbi);
|
||||||
::mdbx_dbi_open2(handle_, mdbx::slice(name), MDBX_DB_ACCEDE, &map.dbi);
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case MDBX_SUCCESS:
|
case MDBX_SUCCESS:
|
||||||
clear_map(map);
|
clear_map(map);
|
||||||
@ -1658,12 +1652,11 @@ __cold bool txn::clear_map(const ::std::string_view &name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__cold bool txn::rename_map(const ::std::string_view &old_name,
|
__cold bool txn::rename_map(const ::mdbx::slice &old_name,
|
||||||
const ::std::string_view &new_name,
|
const ::mdbx::slice &new_name,
|
||||||
bool throw_if_absent) {
|
bool throw_if_absent) {
|
||||||
map_handle map;
|
map_handle map;
|
||||||
const int err = ::mdbx_dbi_open2(handle_, mdbx::slice(old_name),
|
const int err = ::mdbx_dbi_open2(handle_, old_name, MDBX_DB_ACCEDE, &map.dbi);
|
||||||
MDBX_DB_ACCEDE, &map.dbi);
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case MDBX_SUCCESS:
|
case MDBX_SUCCESS:
|
||||||
rename_map(map, new_name);
|
rename_map(map, new_name);
|
||||||
@ -1681,20 +1674,10 @@ __cold bool txn::rename_map(const ::std::string_view &old_name,
|
|||||||
__cold bool txn::rename_map(const ::std::string &old_name,
|
__cold bool txn::rename_map(const ::std::string &old_name,
|
||||||
const ::std::string &new_name,
|
const ::std::string &new_name,
|
||||||
bool throw_if_absent) {
|
bool throw_if_absent) {
|
||||||
return rename_map(::std::string_view(old_name), ::std::string_view(new_name),
|
return rename_map(::mdbx::slice(old_name), ::mdbx::slice(new_name),
|
||||||
throw_if_absent);
|
throw_if_absent);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
__cold bool txn::rename_map(const ::std::string &old_name,
|
|
||||||
const ::std::string &new_name,
|
|
||||||
bool throw_if_absent) {
|
|
||||||
return rename_map(old_name.c_str(), new_name.c_str(), throw_if_absent);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __cpp_lib_string_view >= 201606L */
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void cursor_managed::close() {
|
void cursor_managed::close() {
|
||||||
|
Loading…
Reference in New Issue
Block a user