The libmdbx C API header file. More...
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/uio.h>
Go to the source code of this file.
Classes | |
struct | MDBX_version_info |
libmdbx version information, More... | |
struct | MDBX_build_info |
libmdbx build information More... | |
struct | MDBX_stat |
Statistics for a table in the environment. More... | |
struct | MDBX_envinfo |
Information about the environment. More... | |
struct | MDBX_txn_info |
Information about the transaction. More... | |
struct | MDBX_commit_latency |
Latency of commit stages in 1/65536 of seconds units. More... | |
struct | MDBX_canary |
The fours integers markers (aka "canary") associated with the environment. More... | |
struct | MDBX_chk_line_t |
Виртуальная строка отчета, формируемого при проверке целостности базы данных. More... | |
struct | MDBX_chk_issue_t |
Проблема обнаруженная при проверке целостности базы данных. More... | |
struct | MDBX_chk_scope_t |
Иерархический контекст при проверке целостности базы данных. More... | |
struct | MDBX_chk_histogram |
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД. More... | |
struct | MDBX_chk_table_t |
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных. More... | |
struct | MDBX_chk_context_t |
Контекст проверки целостности базы данных. More... | |
struct | MDBX_chk_callbacks_t |
Набор функций обратного вызова используемых при проверке целостности базы данных. More... | |
struct | MDBX_version_info.git |
struct | MDBX_envinfo.mi_geo |
struct | MDBX_envinfo.mi_bootid |
A mostly unique ID that is regenerated on each boot. More... | |
struct | MDBX_envinfo.mi_bootid.current |
struct | MDBX_envinfo.mi_bootid.meta |
struct | MDBX_envinfo.mi_pgop_stat |
struct | MDBX_envinfo.mi_dxbid |
struct | MDBX_commit_latency.gc_prof |
Информация для профилирования работы GC. More... | |
struct | MDBX_commit_latency.gc_prof.pnl_merge_work |
struct | MDBX_commit_latency.gc_prof.pnl_merge_self |
union | MDBX_chk_scope_t.usr_z |
union | MDBX_chk_scope_t.usr_v |
union | MDBX_chk_scope_t.usr_o |
struct | MDBX_chk_histogram.ranges |
struct | MDBX_chk_table_t.pages |
struct | MDBX_chk_table_t.histogram |
struct | MDBX_chk_context_t.result |
Macros | |
#define | LIBMDBX_H |
#define | __has_c_attribute(x) |
#define | __has_c_attribute_qualified(x) |
#define | __has_cpp_attribute_qualified(x) |
#define | __has_C23_or_CXX_attribute(x) |
#define | __has_exceptions_disabled (0) |
#define | MDBX_PURE_FUNCTION [[gnu::pure]] |
The 'pure' function attribute for optimization. | |
#define | MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]] |
The 'pure nothrow' function attribute for optimization. | |
#define | MDBX_CONST_FUNCTION [[gnu::const]] |
The 'const' function attribute for optimization. | |
#define | MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]] |
The 'const nothrow' function attribute for optimization. | |
#define | LIBMDBX_INLINE_API(TYPE, NAME, ARGS) |
Auxiliary macro for robustly define the both inline version of API function and non-inline fallback dll-exported version for applications linked with old version of libmdbx, with a strictly ODR-common implementation. Thus, we emulate __extern_inline for all compilers, including non-GNU ones. | |
#define | MDBX_CXX17_NOEXCEPT noexcept |
#define | MDBX_CXX01_CONSTEXPR constexpr |
#define | MDBX_CXX01_CONSTEXPR_VAR constexpr |
#define | MDBX_CXX11_CONSTEXPR constexpr |
#define | MDBX_CXX11_CONSTEXPR_VAR constexpr |
#define | MDBX_CXX14_CONSTEXPR constexpr |
#define | MDBX_CXX14_CONSTEXPR_VAR constexpr |
#define | MDBX_NORETURN [[noreturn]] |
#define | MDBX_MAYBE_UNUSED [[maybe_unused]] |
#define | MDBX_VERSION_MAJOR 0 |
#define | MDBX_VERSION_MINOR 13 |
#define | LIBMDBX_API __dll_export |
#define | LIBMDBX_API_TYPE |
#define | LIBMDBX_VERINFO_API __dll_export |
#define | MDBX_LOCKNAME "/mdbx.lck" |
The name of the lock file in the environment without using MDBX_NOSUBDIR. | |
#define | MDBX_DATANAME "/mdbx.dat" |
The name of the data file in the environment without using MDBX_NOSUBDIR. | |
#define | MDBX_LOCK_SUFFIX "-lck" |
The suffix of the lock file when MDBX_NOSUBDIR is used. | |
#define | MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1) |
The "don't change `logger`" value for mdbx_setup_debug() | |
#define | MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt *)(intptr_t)-1) |
#define | MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated() |
#define | mdbx_env_openT(env, pathname, flags, mode) |
#define | mdbx_env_deleteT(pathname, mode) |
#define | mdbx_env_copyT(env, dest, flags) |
#define | mdbx_txn_copy2pathnameT(txn, dest, flags) |
#define | mdbx_env_get_pathT(env, dest) |
#define | MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1)) |
The EPSILON value for mdbx_estimate_range() | |
#define | mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) |
#define | mdbx_preopen_snapinfoT(pathname, info, bytes) |
#define | MDBX_CHK_MAIN ((void *)((ptrdiff_t)0)) |
Pseudo-name for MainDB. | |
#define | MDBX_CHK_GC ((void *)((ptrdiff_t)-1)) |
Pseudo-name for GarbageCollectorDB. | |
#define | MDBX_CHK_META ((void *)((ptrdiff_t)-2)) |
Pseudo-name for MetaPages. | |
Typedefs | |
typedef int | mdbx_filehandle_t |
typedef pid_t | mdbx_pid_t |
typedef pthread_t | mdbx_tid_t |
typedef mode_t | mdbx_mode_t |
typedef struct MDBX_env | MDBX_env |
Opaque structure for a database environment. | |
typedef struct MDBX_txn | MDBX_txn |
Opaque structure for a transaction handle. | |
typedef uint32_t | MDBX_dbi |
A handle for an individual table (key-value spaces) in the environment. | |
typedef struct MDBX_cursor | MDBX_cursor |
Opaque structure for navigating through a table. | |
typedef struct iovec | MDBX_val |
Generic structure used for passing keys and data in and out of the table. . | |
typedef void | MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt, va_list args) noexcept |
A debug-logger callback function, called before printing the message and aborting. | |
typedef void | MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg, unsigned length) noexcept |
typedef void | MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function, unsigned line) noexcept |
A callback function for most MDBX assert() failures, called before printing the message and aborting. | |
typedef int | MDBX_cmp_func(const MDBX_val *a, const MDBX_val *b) noexcept |
A callback function used to compare two keys in a table. | |
typedef int | MDBX_table_enum_func(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, const struct MDBX_stat *stat, MDBX_dbi dbi) noexcept |
Функция обратного вызова для перечисления пользовательских именованных таблиц. | |
typedef int(* | MDBX_preserve_func) (void *context, MDBX_val *target, const void *src, size_t bytes) |
typedef int | MDBX_predicate_func(void *context, MDBX_val *key, MDBX_val *value, void *arg) noexcept |
Тип предикативных функций обратного вызова используемых mdbx_cursor_scan() и mdbx_cursor_scan_from() для пробирования пар ключ-значения. | |
typedef int | MDBX_reader_list_func(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid, uint64_t lag, size_t bytes_used, size_t bytes_retained) noexcept |
A callback function used to enumerate the reader lock table. | |
typedef int | MDBX_hsr_func(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard, unsigned gap, size_t space, int retry) noexcept |
A Handle-Slow-Readers callback function to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. | |
typedef struct MDBX_chk_user_table_cookie | MDBX_chk_user_table_cookie_t |
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение, при проверке целостности базы данных. | |
Functions | |
LIBMDBX_API int | mdbx_setup_debug (MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func *logger) |
Setup global log-level, debug options and debug logger. | |
LIBMDBX_API int | mdbx_setup_debug_nofmt (MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size) |
LIBMDBX_API int | mdbx_env_set_assert (MDBX_env *env, MDBX_assert_func *func) |
Set or reset the assert() callback of the environment. | |
LIBMDBX_API const char * | mdbx_dump_val (const MDBX_val *key, char *const buf, const size_t bufsize) |
Dump given MDBX_val to the buffer. | |
MDBX_NORETURN LIBMDBX_API void | mdbx_panic (const char *fmt,...) MDBX_PRINTF_ARGS(1 |
Panics with message and causes abnormal process termination. | |
MDBX_NORETURN LIBMDBX_API void MDBX_NORETURN LIBMDBX_API void | mdbx_assert_fail (const MDBX_env *env, const char *msg, const char *func, unsigned line) |
Panics with asserton failed message and causes abnormal process termination. | |
LIBMDBX_API const char * | mdbx_strerror (int errnum) |
Return a string describing a given error code. | |
LIBMDBX_API const char * | mdbx_strerror_r (int errnum, char *buf, size_t buflen) |
Return a string describing a given error code. | |
LIBMDBX_API const char * | mdbx_liberr2str (int errnum) |
LIBMDBX_API const char * | mdbx_strerror_ANSI2OEM (int errnum) |
LIBMDBX_API const char * | mdbx_strerror_r_ANSI2OEM (int errnum, char *buf, size_t buflen) |
LIBMDBX_API int | mdbx_env_create (MDBX_env **penv) |
Create an MDBX environment instance. | |
LIBMDBX_API int | mdbx_env_set_option (MDBX_env *env, const MDBX_option_t option, uint64_t value) |
Sets the value of a extra runtime options for an environment. | |
LIBMDBX_API int | mdbx_env_get_option (const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue) |
Gets the value of extra runtime options from an environment. | |
LIBMDBX_API int | mdbx_env_open (MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode) |
Open an environment instance. | |
LIBMDBX_API int | mdbx_env_openW (MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode) |
Open an environment instance. | |
LIBMDBX_API int | mdbx_env_delete (const char *pathname, MDBX_env_delete_mode_t mode) |
Delete the environment's files in a proper and multiprocess-safe way. | |
LIBMDBX_API int | mdbx_env_deleteW (const wchar_t *pathname, MDBX_env_delete_mode_t mode) |
Delete the environment's files in a proper and multiprocess-safe way. | |
LIBMDBX_API int | mdbx_env_copy (MDBX_env *env, const char *dest, MDBX_copy_flags_t flags) |
Copy an MDBX environment to the specified path, with options. | |
LIBMDBX_API int | mdbx_txn_copy2pathname (MDBX_txn *txn, const char *dest, MDBX_copy_flags_t flags) |
Copy an MDBX environment by given read transaction to the specified path, with options. | |
LIBMDBX_API int | mdbx_env_copyW (MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags) |
Copy an MDBX environment to the specified path, with options. | |
LIBMDBX_API int | mdbx_txn_copy2pathnameW (MDBX_txn *txn, const wchar_t *dest, MDBX_copy_flags_t flags) |
Copy an MDBX environment by given read transaction to the specified path, with options. | |
LIBMDBX_API int | mdbx_env_copy2fd (MDBX_env *env, mdbx_filehandle_t fd, MDBX_copy_flags_t flags) |
Copy an environment to the specified file descriptor, with options. | |
LIBMDBX_API int | mdbx_txn_copy2fd (MDBX_txn *txn, mdbx_filehandle_t fd, MDBX_copy_flags_t flags) |
Copy an environment by given read transaction to the specified file descriptor, with options. | |
LIBMDBX_API int | mdbx_env_stat_ex (const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes) |
Return statistics about the MDBX environment. | |
int | mdbx_env_stat (const MDBX_env *env, MDBX_stat *stat, size_t bytes) |
Return statistics about the MDBX environment. | |
LIBMDBX_API int | mdbx_env_info_ex (const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes) |
Return information about the MDBX environment. | |
int | mdbx_env_info (const MDBX_env *env, MDBX_envinfo *info, size_t bytes) |
Return information about the MDBX environment. | |
LIBMDBX_API int | mdbx_env_sync_ex (MDBX_env *env, bool force, bool nonblock) |
Flush the environment data buffers to disk. | |
int | mdbx_env_sync (MDBX_env *env) |
The shortcut to calling mdbx_env_sync_ex() with the force=true and nonblock=false arguments. | |
int | mdbx_env_sync_poll (MDBX_env *env) |
The shortcut to calling mdbx_env_sync_ex() with the force=false and nonblock=true arguments. | |
int | mdbx_env_set_syncbytes (MDBX_env *env, size_t threshold) |
Sets threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the environment. | |
int | mdbx_env_get_syncbytes (const MDBX_env *env, size_t *threshold) |
Get threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the environment. | |
int | mdbx_env_set_syncperiod (MDBX_env *env, unsigned seconds_16dot16) |
Sets relative period since the last unsteady commit to force flush the data buffers to disk, even of MDBX_SAFE_NOSYNC flag in the environment. | |
int | mdbx_env_get_syncperiod (const MDBX_env *env, unsigned *period_seconds_16dot16) |
Get relative period since the last unsteady commit to force flush the data buffers to disk, even of MDBX_SAFE_NOSYNC flag in the environment. | |
LIBMDBX_API int | mdbx_env_close_ex (MDBX_env *env, bool dont_sync) |
Close the environment and release the memory map. | |
int | mdbx_env_close (MDBX_env *env) |
The shortcut to calling mdbx_env_close_ex() with the dont_sync=false argument. | |
LIBMDBX_API int | mdbx_env_resurrect_after_fork (MDBX_env *env) |
Восстанавливает экземпляр среды в дочернем процессе после ветвления родительского процесса посредством fork() и родственных системных вызовов. | |
LIBMDBX_API int | mdbx_env_warmup (const MDBX_env *env, const MDBX_txn *txn, MDBX_warmup_flags_t flags, unsigned timeout_seconds_16dot16) |
Warms up the database by loading pages into memory, optionally lock ones. | |
LIBMDBX_API int | mdbx_env_set_flags (MDBX_env *env, MDBX_env_flags_t flags, bool onoff) |
Set environment flags. | |
LIBMDBX_API int | mdbx_env_get_flags (const MDBX_env *env, unsigned *flags) |
Get environment flags. | |
LIBMDBX_API int | mdbx_env_get_path (const MDBX_env *env, const char **dest) |
Return the path that was used in mdbx_env_open(). | |
LIBMDBX_API int | mdbx_env_get_pathW (const MDBX_env *env, const wchar_t **dest) |
Return the path that was used in mdbx_env_open(). | |
LIBMDBX_API int | mdbx_env_get_fd (const MDBX_env *env, mdbx_filehandle_t *fd) |
Return the file descriptor for the given environment. | |
LIBMDBX_API int | mdbx_env_set_geometry (MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper, intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize) |
Set all size-related parameters of environment, including page size and the min/max size of the memory map. | |
int | mdbx_env_set_mapsize (MDBX_env *env, size_t size) |
LIBMDBX_API int | mdbx_is_readahead_reasonable (size_t volume, intptr_t redundancy) |
Find out whether to use readahead or not, based on the given database size and the amount of available memory. | |
intptr_t | mdbx_limits_pgsize_min (void) |
Returns the minimal database page size in bytes. | |
intptr_t | mdbx_limits_pgsize_max (void) |
Returns the maximal database page size in bytes. | |
LIBMDBX_API intptr_t | mdbx_limits_dbsize_min (intptr_t pagesize) |
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_dbsize_max (intptr_t pagesize) |
Returns maximal database size in bytes for given page size, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_keysize_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal key size in bytes for given page size and table flags, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_keysize_min (MDBX_db_flags_t flags) |
Returns minimal key size in bytes for given table flags. | |
LIBMDBX_API intptr_t | mdbx_limits_valsize_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal data size in bytes for given page size and table flags, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_valsize_min (MDBX_db_flags_t flags) |
Returns minimal data size in bytes for given table flags. | |
LIBMDBX_API intptr_t | mdbx_limits_pairsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal size of key-value pair to fit in a single page with the given size and table flags, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_valsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags) |
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page with the given page size and table flags, or -1 if pagesize is invalid. | |
LIBMDBX_API intptr_t | mdbx_limits_txnsize_max (intptr_t pagesize) |
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for given page size, or -1 if pagesize is invalid. | |
int | mdbx_env_set_maxreaders (MDBX_env *env, unsigned readers) |
Set the maximum number of threads/reader slots for for all processes interacts with the database. | |
int | mdbx_env_get_maxreaders (const MDBX_env *env, unsigned *readers) |
Get the maximum number of threads/reader slots for the environment. | |
int | mdbx_env_set_maxdbs (MDBX_env *env, MDBX_dbi dbs) |
Set the maximum number of named tables for the environment. | |
int | mdbx_env_get_maxdbs (const MDBX_env *env, MDBX_dbi *dbs) |
Get the maximum number of named tables for the environment. | |
LIBMDBX_API size_t | mdbx_default_pagesize (void) |
Returns the default size of database page for the current system. | |
LIBMDBX_API int | mdbx_get_sysraminfo (intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages) |
Returns basic information about system RAM. This function provides a portable way to get information about available RAM and can be useful in that it returns the same information that libmdbx uses internally to adjust various options and control readahead. | |
LIBMDBX_API int | mdbx_env_get_maxkeysize_ex (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns the maximum size of keys can put. | |
LIBMDBX_API int | mdbx_env_get_maxvalsize_ex (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns the maximum size of data we can put. | |
LIBMDBX_API int | mdbx_env_get_maxkeysize (const MDBX_env *env) |
LIBMDBX_API int | mdbx_env_get_pairsize4page_max (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns maximal size of key-value pair to fit in a single page for specified table flags. | |
LIBMDBX_API int | mdbx_env_get_valsize4page_max (const MDBX_env *env, MDBX_db_flags_t flags) |
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified table flags. | |
LIBMDBX_API int | mdbx_env_set_userctx (MDBX_env *env, void *ctx) |
Sets application information (a context pointer) associated with the environment. | |
LIBMDBX_API void * | mdbx_env_get_userctx (const MDBX_env *env) |
Returns an application information (a context pointer) associated with the environment. | |
LIBMDBX_API int | mdbx_txn_begin_ex (MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn, void *context) |
Create a transaction with a user provided context pointer for use with the environment. | |
int | mdbx_txn_begin (MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) |
Create a transaction for use with the environment. | |
LIBMDBX_API int | mdbx_txn_set_userctx (MDBX_txn *txn, void *ctx) |
Sets application information associated (a context pointer) with the transaction. | |
LIBMDBX_API void * | mdbx_txn_get_userctx (const MDBX_txn *txn) |
Returns an application information (a context pointer) associated with the transaction. | |
LIBMDBX_API int | mdbx_txn_info (const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt) |
Return information about the MDBX transaction. | |
LIBMDBX_API MDBX_env * | mdbx_txn_env (const MDBX_txn *txn) |
Returns the transaction's MDBX_env. | |
LIBMDBX_API MDBX_txn_flags_t | mdbx_txn_flags (const MDBX_txn *txn) |
Return the transaction's flags. | |
LIBMDBX_API uint64_t | mdbx_txn_id (const MDBX_txn *txn) |
Return the transaction's ID. | |
LIBMDBX_API int | mdbx_txn_commit_ex (MDBX_txn *txn, MDBX_commit_latency *latency) |
Commit all the operations of a transaction into the database and collect latency information. | |
int | mdbx_txn_commit (MDBX_txn *txn) |
Commit all the operations of a transaction into the database. | |
LIBMDBX_API int | mdbx_txn_abort (MDBX_txn *txn) |
Abandon all the operations of the transaction instead of saving them. | |
LIBMDBX_API int | mdbx_txn_break (MDBX_txn *txn) |
Marks transaction as broken. | |
LIBMDBX_API int | mdbx_txn_reset (MDBX_txn *txn) |
Reset a read-only transaction. | |
LIBMDBX_API int | mdbx_txn_park (MDBX_txn *txn, bool autounpark) |
Переводит читающую транзакцию в "припаркованное" состояние. | |
LIBMDBX_API int | mdbx_txn_unpark (MDBX_txn *txn, bool restart_if_ousted) |
Распарковывает ранее припаркованную читающую транзакцию. | |
LIBMDBX_API int | mdbx_txn_renew (MDBX_txn *txn) |
Renew a read-only transaction. | |
LIBMDBX_API int | mdbx_canary_put (MDBX_txn *txn, const MDBX_canary *canary) |
Set integers markers (aka "canary") associated with the environment. | |
LIBMDBX_API int | mdbx_canary_get (const MDBX_txn *txn, MDBX_canary *canary) |
Returns fours integers markers (aka "canary") associated with the environment. | |
LIBMDBX_API int | mdbx_dbi_open (MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi) |
Open or Create a named table in the environment. | |
LIBMDBX_API int | mdbx_dbi_open2 (MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, MDBX_dbi *dbi) |
Open or Create a named table in the environment. | |
LIBMDBX_API int | mdbx_dbi_open_ex (MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp) |
Open or Create a named table in the environment with using custom comparison functions. | |
LIBMDBX_API int | mdbx_dbi_open_ex2 (MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp) |
Open or Create a named table in the environment with using custom comparison functions. | |
LIBMDBX_API int | mdbx_dbi_rename (MDBX_txn *txn, MDBX_dbi dbi, const char *name) |
Переименовает таблицу по DBI-дескриптору | |
LIBMDBX_API int | mdbx_dbi_rename2 (MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name) |
Переименовает таблицу по DBI-дескриптору | |
LIBMDBX_API int | mdbx_enumerate_tables (const MDBX_txn *txn, MDBX_table_enum_func *func, void *ctx) |
Перечисляет пользовательские именнованные таблицы. | |
LIBMDBX_API uint64_t | mdbx_key_from_jsonInteger (const int64_t json_integer) |
LIBMDBX_API uint64_t | mdbx_key_from_double (const double ieee754_64bit) |
LIBMDBX_API uint64_t | mdbx_key_from_ptrdouble (const double *const ieee754_64bit) |
LIBMDBX_API uint32_t | mdbx_key_from_float (const float ieee754_32bit) |
LIBMDBX_API uint32_t | mdbx_key_from_ptrfloat (const float *const ieee754_32bit) |
uint64_t | mdbx_key_from_int64 (const int64_t i64) |
uint32_t | mdbx_key_from_int32 (const int32_t i32) |
LIBMDBX_API int64_t | mdbx_jsonInteger_from_key (const MDBX_val) |
LIBMDBX_API double | mdbx_double_from_key (const MDBX_val) |
LIBMDBX_API float | mdbx_float_from_key (const MDBX_val) |
LIBMDBX_API int32_t | mdbx_int32_from_key (const MDBX_val) |
LIBMDBX_API int64_t | mdbx_int64_from_key (const MDBX_val) |
LIBMDBX_API int | mdbx_dbi_stat (const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes) |
Retrieve statistics for a table. | |
LIBMDBX_API int | mdbx_dbi_dupsort_depthmask (const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask) |
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given table. | |
LIBMDBX_API int | mdbx_dbi_flags_ex (const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state) |
Retrieve the DB flags and status for a table handle. | |
int | mdbx_dbi_flags (const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) |
The shortcut to calling mdbx_dbi_flags_ex() with state=NULL for discarding it result. | |
LIBMDBX_API int | mdbx_dbi_close (MDBX_env *env, MDBX_dbi dbi) |
Close a table handle. Normally unnecessary. | |
LIBMDBX_API int | mdbx_drop (MDBX_txn *txn, MDBX_dbi dbi, bool del) |
Empty or delete and close a table. | |
LIBMDBX_API int | mdbx_get (const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data) |
Get items from a table. | |
LIBMDBX_API int | mdbx_get_ex (const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count) |
Get items from a table and optionally number of data items for a given key. | |
LIBMDBX_API int | mdbx_get_equal_or_great (const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data) |
Get equal or great item from a table. | |
LIBMDBX_API int | mdbx_put (MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags) |
Store items into a table. | |
LIBMDBX_API int | mdbx_replace (MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data, MDBX_put_flags_t flags) |
Replace items in a table. | |
LIBMDBX_API int | mdbx_replace_ex (MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver, void *preserver_context) |
LIBMDBX_API int | mdbx_del (MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data) |
Delete items from a table. | |
LIBMDBX_API MDBX_cursor * | mdbx_cursor_create (void *context) |
Create a cursor handle but not bind it to transaction nor DBI-handle. | |
LIBMDBX_API int | mdbx_cursor_set_userctx (MDBX_cursor *cursor, void *ctx) |
Set application information associated with the cursor. | |
LIBMDBX_API void * | mdbx_cursor_get_userctx (const MDBX_cursor *cursor) |
Get the application information associated with the MDBX_cursor. | |
LIBMDBX_API int | mdbx_cursor_bind (const MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi) |
Bind cursor to specified transaction and DBI-handle. | |
LIBMDBX_API int | mdbx_cursor_unbind (MDBX_cursor *cursor) |
Unbind cursor from a transaction. | |
LIBMDBX_API int | mdbx_cursor_reset (MDBX_cursor *cursor) |
Сбрасывает состояние курсора. | |
LIBMDBX_API int | mdbx_cursor_open (const MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor) |
Create a cursor handle for the specified transaction and DBI handle. | |
LIBMDBX_API void | mdbx_cursor_close (MDBX_cursor *cursor) |
Close a cursor handle. | |
LIBMDBX_API int | mdbx_txn_release_all_cursors (const MDBX_txn *txn, bool unbind) |
Unbind or closes all cursors of a given transaction. | |
LIBMDBX_API int | mdbx_cursor_renew (const MDBX_txn *txn, MDBX_cursor *cursor) |
Renew a cursor handle for use within the given transaction. | |
LIBMDBX_API MDBX_txn * | mdbx_cursor_txn (const MDBX_cursor *cursor) |
Return the cursor's transaction handle. | |
LIBMDBX_API MDBX_dbi | mdbx_cursor_dbi (const MDBX_cursor *cursor) |
Return the cursor's table handle. | |
LIBMDBX_API int | mdbx_cursor_copy (const MDBX_cursor *src, MDBX_cursor *dest) |
Copy cursor position and state. | |
LIBMDBX_API int | mdbx_cursor_compare (const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival) |
Сравнивает позицию курсоров. | |
LIBMDBX_API int | mdbx_cursor_get (MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op) |
Retrieve by cursor. | |
LIBMDBX_API int | mdbx_cursor_ignord (MDBX_cursor *cursor) |
Служебная функция для использования в утилитах. | |
LIBMDBX_API int | mdbx_cursor_scan (MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg) |
Сканирует таблицу с использованием передаваемого предиката, с уменьшением сопутствующих накладных расходов. | |
LIBMDBX_API int | mdbx_cursor_scan_from (MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value, MDBX_cursor_op turn_op, void *arg) |
LIBMDBX_API int | mdbx_cursor_get_batch (MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit, MDBX_cursor_op op) |
Retrieve multiple non-dupsort key/value pairs by cursor. | |
LIBMDBX_API int | mdbx_cursor_put (MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags) |
Store by cursor. | |
LIBMDBX_API int | mdbx_cursor_del (MDBX_cursor *cursor, MDBX_put_flags_t flags) |
Delete current key/data pair. | |
LIBMDBX_API int | mdbx_cursor_count (const MDBX_cursor *cursor, size_t *count) |
Return count values (aka duplicates) for current key. | |
LIBMDBX_API int | mdbx_cursor_count_ex (const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes) |
Return count values (aka duplicates) and nested b-tree statistics for current key. | |
LIBMDBX_API int | mdbx_cursor_eof (const MDBX_cursor *cursor) |
Determines whether the cursor is pointed to a key-value pair or not, i.e. was not positioned or points to the end of data. | |
LIBMDBX_API int | mdbx_cursor_on_first (const MDBX_cursor *cursor) |
Determines whether the cursor is pointed to the first key-value pair or not. | |
LIBMDBX_API int | mdbx_cursor_on_first_dup (const MDBX_cursor *cursor) |
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу. | |
LIBMDBX_API int | mdbx_cursor_on_last (const MDBX_cursor *cursor) |
Determines whether the cursor is pointed to the last key-value pair or not. | |
LIBMDBX_API int | mdbx_cursor_on_last_dup (const MDBX_cursor *cursor) |
Определяет стоит ли курсор на последнем или единственном мульти-значении соответствующем ключу. | |
LIBMDBX_API int | mdbx_estimate_distance (const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items) |
Estimates the distance between cursors as a number of elements. | |
LIBMDBX_API int | mdbx_estimate_move (const MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op move_op, ptrdiff_t *distance_items) |
Estimates the move distance. | |
LIBMDBX_API int | mdbx_estimate_range (const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key, const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data, ptrdiff_t *distance_items) |
Estimates the size of a range as a number of elements. | |
LIBMDBX_API int | mdbx_is_dirty (const MDBX_txn *txn, const void *ptr) |
Determines whether the given address is on a dirty database page of the transaction or not. | |
LIBMDBX_API int | mdbx_dbi_sequence (MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment) |
Sequence generation for a table. | |
LIBMDBX_API int | mdbx_cmp (const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b) |
Compare two keys according to a particular table. | |
LIBMDBX_API MDBX_cmp_func * | mdbx_get_keycmp (MDBX_db_flags_t flags) |
Returns default internal key's comparator for given table flags. | |
LIBMDBX_API int | mdbx_dcmp (const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b) |
Compare two data items according to a particular table. | |
LIBMDBX_API MDBX_cmp_func * | mdbx_get_datacmp (MDBX_db_flags_t flags) |
Returns default internal data's comparator for given table flags. | |
LIBMDBX_API int | mdbx_reader_list (const MDBX_env *env, MDBX_reader_list_func *func, void *ctx) |
Enumerate the entries in the reader lock table. | |
LIBMDBX_API int | mdbx_reader_check (MDBX_env *env, int *dead) |
Check for stale entries in the reader lock table. | |
LIBMDBX_API int | mdbx_txn_straggler (const MDBX_txn *txn, int *percent) |
Returns a lag of the reading for the given transaction. | |
LIBMDBX_API int | mdbx_thread_register (const MDBX_env *env) |
Registers the current thread as a reader for the environment. | |
LIBMDBX_API int | mdbx_thread_unregister (const MDBX_env *env) |
Unregisters the current thread as a reader for the environment. | |
LIBMDBX_API int | mdbx_env_set_hsr (MDBX_env *env, MDBX_hsr_func *hsr_callback) |
Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. | |
LIBMDBX_API MDBX_hsr_func * | mdbx_env_get_hsr (const MDBX_env *env) |
Gets current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. | |
LIBMDBX_API int | mdbx_txn_lock (MDBX_env *env, bool dont_wait) |
Acquires write-transaction lock. Provided for custom and/or complex locking scenarios. | |
LIBMDBX_API int | mdbx_txn_unlock (MDBX_env *env) |
Releases write-transaction lock. Provided for custom and/or complex locking scenarios. | |
LIBMDBX_API int | mdbx_env_open_for_recovery (MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable) |
Open an environment instance using specific meta-page for checking and recovery. | |
LIBMDBX_API int | mdbx_env_open_for_recoveryW (MDBX_env *env, const wchar_t *pathname, unsigned target_meta, bool writeable) |
Open an environment instance using specific meta-page for checking and recovery. | |
LIBMDBX_API int | mdbx_env_turn_for_recovery (MDBX_env *env, unsigned target_meta) |
Turn database to the specified meta-page. | |
LIBMDBX_API int | mdbx_preopen_snapinfo (const char *pathname, MDBX_envinfo *info, size_t bytes) |
Получает базовую информацию о БД не открывая её. | |
LIBMDBX_API int | mdbx_preopen_snapinfoW (const wchar_t *pathname, MDBX_envinfo *info, size_t bytes) |
Получает базовую информацию о БД не открывая её. | |
LIBMDBX_API int | mdbx_env_chk (MDBX_env *env, const MDBX_chk_callbacks_t *cb, MDBX_chk_context_t *ctx, const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity, unsigned timeout_seconds_16dot16) |
Проверяет целостность базы данных. | |
LIBMDBX_API int | mdbx_env_chk_encount_problem (MDBX_chk_context_t *ctx) |
Вспомогательная функция для подсчета проблем детектируемых приложением, в том числе, поступающим к приложению через логирование. | |
Variables | |
LIBMDBX_VERINFO_API const struct MDBX_version_info | mdbx_version |
libmdbx version information | |
LIBMDBX_VERINFO_API const struct MDBX_build_info | mdbx_build |
libmdbx build information | |
The libmdbx C API header file.
#define LIBMDBX_H |
libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddable, transactional key-value store, with Apache 2.0 license. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight solutions with extraordinary performance.
libmdbx is superior to LMDB in terms of features and reliability, not inferior in performance. In comparison to LMDB, libmdbx makes many things just work perfectly, not silently and catastrophically break down. libmdbx supports Linux, Windows, MacOS, OSX, iOS, Android, FreeBSD, DragonFly, Solaris, OpenSolaris, OpenIndiana, NetBSD, OpenBSD and other systems compliant with POSIX.1-2008.
Please visit https://libmdbx.dqdkfa.ru for more information, documentation, C++ API description and links to the origin git repo with the source code. Questions, feedback and suggestions are welcome to the Telegram' group https://t.me/libmdbx.
Donations are welcome to ETH 0xD104d8f8B2dC312aaD74899F83EBf3EEBDC1EA3A
. Всё будет хорошо!
#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1)) |
Pseudo-name for GarbageCollectorDB.
#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0)) |
Pseudo-name for MainDB.
#define MDBX_CHK_META ((void *)((ptrdiff_t)-2)) |
Pseudo-name for MetaPages.