libmdbx 0.14.3.8 (2026-08-12T00:57:40+03:00)
One of the fastest compact embeddable key-value ACID storage engine without WAL.
Loading...
Searching...
No Matches
mdbx.h
Go to the documentation of this file.
1
37
38#pragma once
39/*
40 * Tested with, since 2026:
41 * - Elbrus LCC >= 1.28 (http://www.mcst.ru/lcc);
42 * - GNU C >= 11.3;
43 * - CLANG >= 14.0;
44 * - MSVC >= 19.44 (Visual Studio 2022 toolchain v143),
45 * before 2026:
46 * - Elbrus LCC >= 1.23 (http://www.mcst.ru/lcc);
47 * - GNU C >= 4.8;
48 * - CLANG >= 3.9;
49 * - MSVC >= 14.0 (Visual Studio 2015),
50 * but 19.2x could hang due optimizer bug;
51 * - AppleClang.
52 */
53
54#ifndef LIBMDBX_H
55#define LIBMDBX_H
56
57#if defined(__riscv) || defined(__riscv__) || defined(__RISCV) || defined(__RISCV__)
58#warning "The RISC-V architecture is intentionally insecure by design. \
59 Please delete this admonition at your own risk, \
60 if you make such decision informed and consciously. \
61 Refer to https://clck.ru/32d9xH for more information."
62#endif /* RISC-V */
63
64#ifdef _MSC_VER
65#pragma warning(push, 1)
66#pragma warning(disable : 4548) /* expression before comma has no effect; \
67 expected expression with side - effect */
68#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
69 * semantics are not enabled. Specify /EHsc */
70#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
71 * mode specified; termination on exception is \
72 * not guaranteed. Specify /EHsc */
73#endif /* _MSC_VER (warnings) */
74
75/* *INDENT-OFF* */
76/* clang-format off */
157/* *INDENT-ON* */
158/* clang-format on */
159
160#include <stdarg.h>
161#include <stddef.h>
162#include <stdint.h>
163#if !defined(assert)
164#include <assert.h>
165#endif /* assert */
166
167#if defined(_WIN32) || defined(_WIN64)
168#include <windows.h>
169#include <winnt.h>
170#ifndef __mode_t_defined
171typedef unsigned short mdbx_mode_t;
172#else
173typedef mode_t mdbx_mode_t;
174#endif /* __mode_t_defined */
175typedef HANDLE mdbx_filehandle_t;
176typedef DWORD mdbx_pid_t;
177typedef DWORD mdbx_tid_t;
178#else /* Windows */
179#include <errno.h> /* for error codes */
180#include <pthread.h> /* for pthread_t */
181#include <sys/types.h> /* for pid_t */
182#include <sys/uio.h> /* for struct iovec */
183#define HAVE_STRUCT_IOVEC 1
185typedef pid_t mdbx_pid_t;
186typedef pthread_t mdbx_tid_t;
187typedef mode_t mdbx_mode_t;
188#endif /* !Windows */
189
190#ifdef _MSC_VER
191#pragma warning(pop)
192#endif
193
194#define MDBX_AMALGAMATED_SOURCE 1
195
200
201/*----------------------------------------------------------------------------*/
202
203#ifndef __has_attribute
204#define __has_attribute(x) (0)
205#endif /* __has_attribute */
206
207#ifndef __has_c_attribute
208#define __has_c_attribute(x) (0)
209#define __has_c_attribute_qualified(x) 0
210#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
211#define __has_c_attribute_qualified(x) 0
212#elif defined(_MSC_VER)
213/* MSVC don't support `namespace::attr` syntax */
214#define __has_c_attribute_qualified(x) 0
215#else
216#define __has_c_attribute_qualified(x) __has_c_attribute(x)
217#endif /* __has_c_attribute */
218
219#ifndef __has_cpp_attribute
220#define __has_cpp_attribute(x) 0
221#define __has_cpp_attribute_qualified(x) 0
222#elif defined(_MSC_VER) || (__clang__ && __clang__ < 14)
223/* MSVC don't support `namespace::attr` syntax */
224#define __has_cpp_attribute_qualified(x) 0
225#else
226#define __has_cpp_attribute_qualified(x) __has_cpp_attribute(x)
227#endif /* __has_cpp_attribute */
228
229#ifndef __has_C23_or_CXX_attribute
230#if defined(__cplusplus)
231#define __has_C23_or_CXX_attribute(x) __has_cpp_attribute_qualified(x)
232#else
233#define __has_C23_or_CXX_attribute(x) __has_c_attribute_qualified(x)
234#endif
235#endif /* __has_C23_or_CXX_attribute */
236
237#ifndef __has_feature
238#define __has_feature(x) (0)
239#define __has_exceptions_disabled (0)
240#elif !defined(__has_exceptions_disabled)
241#define __has_exceptions_disabled (__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions))
242#endif /* __has_feature */
243
244#ifndef __has_extension
245#define __has_extension(x) __has_feature(x)
246#endif /* __has_extension */
247
248#ifndef __has_builtin
249#define __has_builtin(x) (0)
250#endif /* __has_builtin */
251
258#if defined(DOXYGEN)
259#define MDBX_PURE_FUNCTION [[gnu::pure]]
260#elif __has_C23_or_CXX_attribute(gnu::pure)
261#define MDBX_PURE_FUNCTION [[gnu::pure]]
262#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
263 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
264 __has_exceptions_disabled)
265#define MDBX_PURE_FUNCTION __attribute__((__pure__))
266#else
267#define MDBX_PURE_FUNCTION
268#endif /* MDBX_PURE_FUNCTION */
269
273#if defined(DOXYGEN)
274#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
275#elif __has_C23_or_CXX_attribute(gnu::pure)
276#if __has_C23_or_CXX_attribute(gnu::nothrow)
277#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
278#else
279#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
280#endif
281#elif defined(__GNUC__) || (__has_attribute(__pure__) && __has_attribute(__nothrow__))
282#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
283#elif __has_cpp_attribute(pure)
284#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
285#else
286#define MDBX_NOTHROW_PURE_FUNCTION
287#endif /* MDBX_NOTHROW_PURE_FUNCTION */
288
299#if defined(DOXYGEN)
300#define MDBX_CONST_FUNCTION [[gnu::const]]
301#elif __has_C23_or_CXX_attribute(gnu::const)
302#define MDBX_CONST_FUNCTION [[gnu::const]]
303#elif (defined(__GNUC__) || __has_attribute(__const__)) && \
304 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
305 __has_exceptions_disabled)
306#define MDBX_CONST_FUNCTION __attribute__((__const__))
307#else
308#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
309#endif /* MDBX_CONST_FUNCTION */
310
314#if defined(DOXYGEN)
315#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
316#elif __has_C23_or_CXX_attribute(gnu::const)
317#if __has_C23_or_CXX_attribute(gnu::nothrow)
318#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
319#else
320#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const]]
321#endif
322#elif defined(__GNUC__) || (__has_attribute(__const__) && __has_attribute(__nothrow__))
323#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
324#elif __has_cpp_attribute_qualified(const)
325#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
326#else
327#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
328#endif /* MDBX_NOTHROW_CONST_FUNCTION */
329
333#ifndef MDBX_DEPRECATED
334#ifdef __deprecated
335#define MDBX_DEPRECATED __deprecated
336#elif defined(DOXYGEN) || ((!defined(__GNUC__) || (defined(__clang__) && __clang__ > 19) || __GNUC__ > 5) && \
337 ((defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
338 __has_cpp_attribute(deprecated) >= 201309L) || \
339 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202304L)))
340#define MDBX_DEPRECATED [[deprecated]]
341#elif (defined(__GNUC__) && __GNUC__ > 5) || \
342 (__has_attribute(__deprecated__) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 5))
343#define MDBX_DEPRECATED __attribute__((__deprecated__))
344#elif defined(_MSC_VER)
345#define MDBX_DEPRECATED __declspec(deprecated)
346#else
347#define MDBX_DEPRECATED
348#endif
349#endif /* MDBX_DEPRECATED */
350
351#ifndef MDBX_DEPRECATED_ENUM
352#ifdef __deprecated_enum
353#define MDBX_DEPRECATED_ENUM __deprecated_enum
354#elif defined(DOXYGEN) || \
355 (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
356 __has_cpp_attribute(deprecated) >= 201309L))
357#define MDBX_DEPRECATED_ENUM MDBX_DEPRECATED
358#else
359#define MDBX_DEPRECATED_ENUM /* avoid madness MSVC */
360#endif
361#endif /* MDBX_DEPRECATED_ENUM */
362
363#ifndef __dll_export
364#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
365 defined(__MINGW64__)
366#if defined(__GNUC__) || __has_attribute(__dllexport__)
367#define __dll_export __attribute__((__dllexport__))
368#elif defined(_MSC_VER)
369#define __dll_export __declspec(dllexport)
370#else
371#define __dll_export
372#endif
373#elif defined(__GNUC__) || defined(__clang__) || __has_attribute(__visibility__)
374#define __dll_export __attribute__((__visibility__("default")))
375#else
376#define __dll_export
377#endif
378#endif /* __dll_export */
379
380#ifndef __dll_import
381#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
382 defined(__MINGW64__)
383#if defined(__GNUC__) || __has_attribute(__dllimport__)
384#define __dll_import __attribute__((__dllimport__))
385#elif defined(_MSC_VER)
386#define __dll_import __declspec(dllimport)
387#else
388#define __dll_import
389#endif
390#else
391#define __dll_import
392#endif
393#endif /* __dll_import */
394
399#if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
400#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
401 /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
402 /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
403#else
404#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
405#endif /* LIBMDBX_INLINE_API */
406
408#ifndef MDBX_STRINGIFY
409#define MDBX_STRINGIFY_HELPER(x) #x
410#define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
411#endif /* MDBX_STRINGIFY */
412
413/*----------------------------------------------------------------------------*/
414
415#ifndef __cplusplus
416#ifndef bool
417#define bool _Bool
418#endif
419#ifndef true
420#define true (1)
421#endif
422#ifndef false
423#define false (0)
424#endif
425#endif /* bool without __cplusplus */
426
428#if defined(DOXYGEN)
429#define MDBX_CXX17_NOEXCEPT noexcept
430#elif !defined(__cpp_noexcept_function_type) || __cpp_noexcept_function_type < 201510L
431#define MDBX_CXX17_NOEXCEPT
432#else
433#define MDBX_CXX17_NOEXCEPT noexcept
434#endif /* MDBX_CXX17_NOEXCEPT */
435
437#if defined(DOXYGEN)
438#define MDBX_CXX01_CONSTEXPR constexpr
439#define MDBX_CXX01_CONSTEXPR_VAR constexpr
440#elif !defined(__cplusplus)
441#define MDBX_CXX01_CONSTEXPR __inline
442#define MDBX_CXX01_CONSTEXPR_VAR const
443#elif !defined(DOXYGEN) && \
444 ((__cplusplus < 201103L && defined(__cpp_constexpr) && __cpp_constexpr < 200704L) || \
445 (defined(__LCC__) && __LCC__ < 124) || \
446 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
447 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4))
448#define MDBX_CXX01_CONSTEXPR inline
449#define MDBX_CXX01_CONSTEXPR_VAR const
450#else
451#define MDBX_CXX01_CONSTEXPR constexpr
452#define MDBX_CXX01_CONSTEXPR_VAR constexpr
453#endif /* MDBX_CXX01_CONSTEXPR */
454
457#if defined(DOXYGEN)
458#define MDBX_CXX11_CONSTEXPR constexpr
459#define MDBX_CXX11_CONSTEXPR_VAR constexpr
460#elif !defined(__cplusplus)
461#define MDBX_CXX11_CONSTEXPR __inline
462#define MDBX_CXX11_CONSTEXPR_VAR const
463#elif !defined(DOXYGEN) && \
464 (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || (defined(__LCC__) && __LCC__ < 124) || \
465 (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && !defined(__LCC__)) || \
466 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 5))
467#define MDBX_CXX11_CONSTEXPR inline
468#define MDBX_CXX11_CONSTEXPR_VAR const
469#else
470#define MDBX_CXX11_CONSTEXPR constexpr
471#define MDBX_CXX11_CONSTEXPR_VAR constexpr
472#endif /* MDBX_CXX11_CONSTEXPR */
473
476#if defined(DOXYGEN)
477#define MDBX_CXX14_CONSTEXPR constexpr
478#define MDBX_CXX14_CONSTEXPR_VAR constexpr
479#elif !defined(__cplusplus)
480#define MDBX_CXX14_CONSTEXPR __inline
481#define MDBX_CXX14_CONSTEXPR_VAR const
482#elif defined(DOXYGEN) || \
483 defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
484 ((defined(_MSC_VER) && _MSC_VER >= 1910) || (defined(__clang__) && __clang_major__ > 4) || \
485 (defined(__GNUC__) && __GNUC__ > 6) || (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
486#define MDBX_CXX14_CONSTEXPR constexpr
487#define MDBX_CXX14_CONSTEXPR_VAR constexpr
488#else
489#define MDBX_CXX14_CONSTEXPR inline
490#define MDBX_CXX14_CONSTEXPR_VAR const
491#endif /* MDBX_CXX14_CONSTEXPR */
492
493#if defined(__noreturn)
494#define MDBX_NORETURN __noreturn
495#elif defined(_Noreturn)
496#define MDBX_NORETURN _Noreturn
497#elif defined(DOXYGEN) || (defined(__cplusplus) && __cplusplus >= 201103L) || \
498 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
499#define MDBX_NORETURN [[noreturn]]
500#elif defined(__GNUC__) || __has_attribute(__noreturn__)
501#define MDBX_NORETURN __attribute__((__noreturn__))
502#elif defined(_MSC_VER) && !defined(__clang__)
503#define MDBX_NORETURN __declspec(noreturn)
504#else
505#define MDBX_NORETURN
506#endif /* MDBX_NORETURN */
507
508#ifndef MDBX_PRINTF_ARGS
509#if defined(__GNUC__) || __has_attribute(__format__) || defined(DOXYGEN)
510#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
511#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
512#else
513#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__printf__, format_index, first_arg)))
514#endif /* MinGW */
515#else
516#define MDBX_PRINTF_ARGS(format_index, first_arg)
517#endif
518#endif /* MDBX_PRINTF_ARGS */
519
520#if defined(DOXYGEN) || \
521 (defined(__cplusplus) && __cplusplus >= 201603L && __has_cpp_attribute(maybe_unused) && \
522 __has_cpp_attribute(maybe_unused) >= 201603L && (!defined(__clang__) || __clang__ > 19)) || \
523 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
524#define MDBX_MAYBE_UNUSED [[maybe_unused]]
525#elif defined(__GNUC__) || __has_attribute(__unused__)
526#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
527#else
528#define MDBX_MAYBE_UNUSED
529#endif /* MDBX_MAYBE_UNUSED */
530
531#if __has_attribute(no_sanitize) || defined(DOXYGEN)
532#define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
533#else
534#define MDBX_NOSANITIZE_ENUM
535#endif /* MDBX_NOSANITIZE_ENUM */
536
537/* Oh, below are some songs and dances since:
538 * - C++ requires explicit definition of the necessary operators.
539 * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
540 * the constexpr feature which is broken in most old compilers;
541 * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
542#if !defined(MDBX_DEFINE_ENUM_FLAG_OPERATORS) && !defined(DOXYGEN)
543
544#ifdef __cplusplus
545#if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || (defined(__LCC__) && __LCC__ < 124) || \
546 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
547 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4)
548/* The constexpr feature is not available or (may be) broken */
549#define MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
550#else
551/* C always allows these operators for enums */
552#define MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
553#endif /* __cpp_constexpr */
554
557#define MDBX_DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
558 extern "C++" { \
559 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { return ENUM(unsigned(a) | unsigned(b)); } \
560 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, ENUM b) { return a = a | b; } \
561 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { return ENUM(unsigned(a) & unsigned(b)); } \
562 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, unsigned b) { return ENUM(unsigned(a) & b); } \
563 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, ENUM b) { return ENUM(a & unsigned(b)); } \
564 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, ENUM b) { return a = a & b; } \
565 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, unsigned b) { return a = a & b; } \
566 MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
567 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { return ENUM(unsigned(a) ^ unsigned(b)); } \
568 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, ENUM b) { return a = a ^ b; } \
569 }
570#else /* __cplusplus */
571/* nope for C since it always allows these operators for enums */
572#define MDBX_DEFINE_ENUM_FLAG_OPERATORS(ENUM)
573#define MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
574#endif /* !__cplusplus */
575
576#elif !defined(MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS)
577
578#ifdef __cplusplus
579/* MDBX_DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
580#define MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
581#else
582/* C always allows these operators for enums */
583#define MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
584#endif
585
586#endif /* MDBX_DEFINE_ENUM_FLAG_OPERATORS */
587
588#ifndef MDBX_LIKELY
589#if defined(DOXYGEN) || (defined(__GNUC__) || __has_builtin(__builtin_expect)) && !defined(__COVERITY__)
590#define MDBX_LIKELY(cond) __builtin_expect(!!(cond), 1)
591#else
592#define MDBX_LIKELY(x) (x)
593#endif
594#endif /* MDBX_LIKELY */
595
596#ifndef MDBX_UNLIKELY
597#if defined(DOXYGEN) || (defined(__GNUC__) || __has_builtin(__builtin_expect)) && !defined(__COVERITY__)
598#define MDBX_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
599#else
600#define MDBX_UNLIKELY(x) (x)
601#endif
602#endif /* MDBX_UNLIKELY */
603
604#if defined(DOXYGEN) || (defined(MDBX_CHECKING) && MDBX_CHECKING > 0) || (defined(MDBX_DEBUG) && MDBX_DEBUG > 0)
605#define MDBX_INLINE_API_ASSERT(expr) \
606 do { \
607 if (MDBX_UNLIKELY(!(expr))) \
608 mdbx_assert_fail(#expr, __func__, __LINE__); \
609 } while (0)
610#else
611/* clang-format off */
612#define MDBX_INLINE_API_ASSERT(expr) do {} while(0)
613/* clang-format on */
614#endif /* MDBX_INLINE_API_ASSERT */
615
617
618/*----------------------------------------------------------------------------*/
619
622
623#ifdef __cplusplus
624extern "C" {
625#endif
626
627/* MDBX version 0.14.x */
628#define MDBX_VERSION_MAJOR 0
629#define MDBX_VERSION_MINOR 14
630
631#ifndef LIBMDBX_API
632#if defined(LIBMDBX_EXPORTS) || defined(DOXYGEN)
633#define LIBMDBX_API __dll_export
634#elif defined(LIBMDBX_IMPORTS)
635#define LIBMDBX_API __dll_import
636#else
637#define LIBMDBX_API
638#endif
639#endif /* LIBMDBX_API */
640
641#ifdef __cplusplus
642#if defined(__clang__) || __has_attribute(type_visibility) || defined(DOXYGEN)
643#define LIBMDBX_API_TYPE LIBMDBX_API __attribute__((type_visibility("default")))
644#else
645#define LIBMDBX_API_TYPE LIBMDBX_API
646#endif
647#else
648#define LIBMDBX_API_TYPE
649#endif /* LIBMDBX_API_TYPE */
650
651#if defined(LIBMDBX_IMPORTS)
652#define LIBMDBX_VERINFO_API __dll_import
653#else
654#define LIBMDBX_VERINFO_API __dll_export
655#endif /* LIBMDBX_VERINFO_API */
656
659 uint16_t major;
660 uint16_t minor;
661 uint16_t patch;
662 uint16_t tweak;
663 const char *semver_prerelease;
664 struct {
665 const char *datetime;
666 const char *tree;
667 const char *commit;
668 const char *describe;
669 } git;
670 const char *sourcery;
672
677 const char *datetime;
678 const char *target;
679 const char *options;
680 const char *compiler;
681 const char *flags;
682 const char *metadata;
686
687#if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
688/* MDBX internally uses global and thread local storage destructors to
689 * automatically (de)initialization, releasing reader lock table slots
690 * and so on.
691 *
692 * If MDBX built as a DLL this is done out-of-the-box by DllEntry() function,
693 * which called automatically by Windows core with passing corresponding reason
694 * argument.
695 *
696 * Otherwise, if MDBX was built not as a DLL, some black magic
697 * may be required depending of Windows version:
698 *
699 * - Modern Windows versions, including Windows Vista and later, provides
700 * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
701 * or dll file). In this case, MDBX capable of doing all automatically,
702 * therefore you DON'T NEED to call mdbx_module_handler()
703 * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
704 *
705 * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
706 * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
707 * of your DLL or application,
708 * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
709 *
710 * Therefore, building MDBX as a DLL is recommended for all version of Windows.
711 * So, if you doubt, just build MDBX as the separate DLL and don't care about
712 * the MDBX_MANUAL_MODULE_HANDLER. */
713
714#ifndef _WIN32_WINNT
715#error Non-dll build libmdbx requires target Windows version \
716 to be explicitly defined via _WIN32_WINNT for properly \
717 handling thread local storage destructors.
718#endif /* _WIN32_WINNT */
719
720#if _WIN32_WINNT >= 0x0600 /* Windows Vista */
721/* As described above mdbx_module_handler() is NOT needed for Windows Vista
722 * and later. */
723#define MDBX_MANUAL_MODULE_HANDLER 0
724#else
725/* As described above mdbx_module_handler() IS REQUIRED for Windows versions
726 * prior to Windows Vista. */
727#define MDBX_MANUAL_MODULE_HANDLER 1
728void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason, PVOID reserved);
729#endif
730
731#endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
732
733/* OPACITY STRUCTURES *********************************************************/
734
739#ifndef __cplusplus
740typedef struct MDBX_env MDBX_env;
741#else
742struct MDBX_env;
743#endif
744
750#ifndef __cplusplus
751typedef struct MDBX_txn MDBX_txn;
752#else
753struct MDBX_txn;
754#endif
755
763typedef uint32_t MDBX_dbi;
764
769#ifndef __cplusplus
771#else
772struct MDBX_cursor;
773#endif
774
788#ifndef HAVE_STRUCT_IOVEC
789struct iovec {
790 void *iov_base;
791 size_t iov_len;
792};
793#define HAVE_STRUCT_IOVEC
794#endif /* HAVE_STRUCT_IOVEC */
795
796#if defined(__sun) || defined(__SVR4) || defined(__svr4__)
797/* The `iov_len` is signed on Sun/Solaris.
798 * So define custom MDBX_val to avoid a lot of warnings. */
799struct MDBX_val {
800 void *iov_base;
801 size_t iov_len;
802};
803#ifndef __cplusplus
804typedef struct MDBX_val MDBX_val;
805#endif
806#else /* SunOS */
807typedef struct iovec MDBX_val;
808#endif /* ! SunOS */
809
812 MDBX_MAX_DBI = UINT32_C(32765),
813
815 MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
816
819
822};
823
824/* THE FILES *******************************************************************
825 * At the file system level, the environment corresponds to a pair of files. */
826
827#ifndef MDBX_LOCKNAME
829#if !(defined(_WIN32) || defined(_WIN64))
830#define MDBX_LOCKNAME "/mdbx.lck"
831#else
832#define MDBX_LOCKNAME_W L"\\mdbx.lck"
833#define MDBX_LOCKNAME_A "\\mdbx.lck"
834#ifdef UNICODE
835#define MDBX_LOCKNAME MDBX_LOCKNAME_W
836#else
837#define MDBX_LOCKNAME MDBX_LOCKNAME_A
838#endif /* UNICODE */
839#endif /* Windows */
840#endif /* MDBX_LOCKNAME */
841#ifndef MDBX_DATANAME
844#if !(defined(_WIN32) || defined(_WIN64))
845#define MDBX_DATANAME "/mdbx.dat"
846#else
847#define MDBX_DATANAME_W L"\\mdbx.dat"
848#define MDBX_DATANAME_A "\\mdbx.dat"
849#ifdef UNICODE
850#define MDBX_DATANAME MDBX_DATANAME_W
851#else
852#define MDBX_DATANAME MDBX_DATANAME_A
853#endif /* UNICODE */
854#endif /* Windows */
855#endif /* MDBX_DATANAME */
856
857#ifndef MDBX_LOCK_SUFFIX
859#if !(defined(_WIN32) || defined(_WIN64))
860#define MDBX_LOCK_SUFFIX "-lck"
861#else
862#define MDBX_LOCK_SUFFIX_W L"-lck"
863#define MDBX_LOCK_SUFFIX_A "-lck"
864#ifdef UNICODE
865#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_W
866#else
867#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_A
868#endif /* UNICODE */
869#endif /* Windows */
870#endif /* MDBX_LOCK_SUFFIX */
871
872/* DEBUG & LOGGING ************************************************************/
873
877
933
977MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_debug_flags)
978
979
990typedef void (*MDBX_debug_func)(MDBX_log_level_t log_level, const char *function, int line, const char *fmt,
991 va_list args) MDBX_CXX17_NOEXCEPT;
992
994#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func)(intptr_t)-1)
995
1009
1018typedef void (*MDBX_debug_func_nofmt)(MDBX_log_level_t log_level, const char *function, int line, const char *msg,
1019 unsigned length) MDBX_CXX17_NOEXCEPT;
1020
1022#define MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt)(intptr_t)-1)
1023
1042 MDBX_debug_func_nofmt logger, char *logger_buffer, size_t logger_buffer_size);
1043
1056typedef void (*MDBX_panic_func)(const char *msg, const char *function, unsigned line, const void *obj,
1057 const char *obj_class) MDBX_CXX17_NOEXCEPT;
1058
1060MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const char *msg, const char *func, unsigned line);
1061
1066
1076LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize);
1077
1079
1084typedef enum MDBX_env_flags {
1086
1092 MDBX_VALIDATION = UINT32_C(0x00002000),
1093
1110 MDBX_NOSUBDIR = UINT32_C(0x4000),
1111
1128 MDBX_RDONLY = UINT32_C(0x20000),
1129
1158 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1159
1173 MDBX_ACCEDE = UINT32_C(0x40000000),
1174
1204 MDBX_WRITEMAP = UINT32_C(0x80000),
1205
1254 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1255
1275 MDBX_NORDAHEAD = UINT32_C(0x800000),
1276
1298 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1299
1322 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1323
1325 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1326
1327 /* SYNC MODES****************************************************************/
1369
1380
1397 MDBX_NOMETASYNC = UINT32_C(0x40000),
1398
1448 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1449
1492
1495MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1496
1497
1501typedef enum MDBX_txn_flags {
1507
1513
1520#if MDBX_CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1522#else
1523 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1524#endif
1525
1527 MDBX_TXN_TRY = UINT32_C(0x10000000),
1528
1531
1535
1539
1540 /* Transaction state flags ---------------------------------------------- */
1541
1545 MDBX_TXN_INVALID = INT32_MIN,
1546
1551
1556
1561
1566
1571
1576
1583
1590
1596MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1597
1598
1602typedef enum MDBX_db_flags {
1605
1607 MDBX_REVERSEKEY = UINT32_C(0x02),
1608
1610 MDBX_DUPSORT = UINT32_C(0x04),
1611
1617 MDBX_INTEGERKEY = UINT32_C(0x08),
1618
1621 MDBX_DUPFIXED = UINT32_C(0x10),
1622
1626 MDBX_INTEGERDUP = UINT32_C(0x20),
1627
1629 MDBX_REVERSEDUP = UINT32_C(0x40),
1630
1632 MDBX_CREATE = UINT32_C(0x40000),
1633
1646MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1647
1648
1652typedef enum MDBX_put_flags {
1655
1657 MDBX_NOOVERWRITE = UINT32_C(0x10),
1658
1661 MDBX_NODUPDATA = UINT32_C(0x20),
1662
1667 MDBX_CURRENT = UINT32_C(0x40),
1668
1672 MDBX_ALLDUPS = UINT32_C(0x80),
1673
1676 MDBX_RESERVE = UINT32_C(0x10000),
1677
1680 MDBX_APPEND = UINT32_C(0x20000),
1681
1685 MDBX_APPENDDUP = UINT32_C(0x40000),
1686
1689 MDBX_MULTIPLE = UINT32_C(0x80000)
1691MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1692
1693
1727MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1728
1729
1854
1860typedef enum MDBX_error {
1863
1866
1869
1872
1875
1878
1881
1884
1887 MDBX_PANIC = -30795,
1888
1891
1894
1897
1900
1903
1906
1910
1913
1922
1930
1933
1938
1942
1946
1949
1952
1955 MDBX_BUSY = -30778,
1956
1959
1962
1967
1971
1974
1978
1982
1985
1990
1993
1997
2000 MDBX_OUSTED = -30411,
2001
2004
2008
2009 /* The last of MDBX-added error codes */
2011
2012#if defined(_WIN32) || defined(_WIN64)
2013 MDBX_ENODATA = ERROR_HANDLE_EOF,
2014 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
2015 MDBX_EACCESS = ERROR_ACCESS_DENIED,
2016 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
2017 MDBX_EROFS = ERROR_FILE_READ_ONLY,
2018 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
2019 MDBX_EIO = ERROR_WRITE_FAULT,
2020 MDBX_EPERM = ERROR_INVALID_FUNCTION,
2021 MDBX_EINTR = ERROR_CANCELLED,
2022 MDBX_EEXIST = ERROR_FILE_EXISTS,
2023 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
2024 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
2025 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
2026#else /* Windows */
2027#if defined(ENODATA) || defined(DOXYGEN)
2028 MDBX_ENODATA = ENODATA,
2029#else
2030 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2031#endif /* ENODATA */
2032 MDBX_EINVAL = EINVAL,
2034 MDBX_ENOMEM = ENOMEM,
2035 MDBX_EROFS = EROFS,
2036#if defined(ENOTSUP) || defined(DOXYGEN)
2037 MDBX_ENOSYS = ENOTSUP,
2038#else
2039 MDBX_ENOSYS = ENOSYS,
2040#endif /* ENOTSUP */
2042 MDBX_EPERM = EPERM,
2043 MDBX_EINTR = EINTR,
2044 MDBX_EEXIST = EEXIST,
2046#if defined(EREMOTEIO) || defined(DOXYGEN)
2048 MDBX_EREMOTE = EREMOTEIO,
2049#else
2050 MDBX_EREMOTE = ENOTBLK,
2051#endif /* EREMOTEIO */
2053#endif /* !Windows */
2054} MDBX_error_t;
2055
2074LIBMDBX_API const char *mdbx_strerror(int errnum);
2075
2100LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2102
2103#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2108LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2109
2114LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen);
2115#endif /* Bit of Windows' madness */
2116
2132
2465
2476LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value);
2477
2488LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue);
2489
2569LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2570
2571#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2575LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2576#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_openW(env, pathname, flags, mode)
2577#else
2578#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_open(env, pathname, flags, mode)
2579#endif /* Windows */
2580
2598
2619
2620#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2625LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode);
2626#define mdbx_env_deleteA(pathname, mode) mdbx_env_delete(pathname, mode)
2627#ifdef UNICODE
2628#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteW(pathname, mode)
2629#else
2630#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteA(pathname, mode)
2631#endif /* UNICODE */
2632#else
2633#define mdbx_env_deleteT(pathname, mode) mdbx_env_delete(pathname, mode)
2634#endif /* Windows */
2635
2689LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags);
2690
2744
2745#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2750LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags);
2751#define mdbx_env_copyT(env, dest, flags) mdbx_env_copyW(env, dest, flags)
2752
2758#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathnameW(txn, dest, path)
2759#else
2760#define mdbx_env_copyT(env, dest, flags) mdbx_env_copy(env, dest, flags)
2761#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathname(txn, dest, path)
2762#endif /* Windows */
2763
2788
2812
2817 uint32_t ms_psize;
2819 uint32_t ms_depth;
2821 uint64_t ms_leaf_pages;
2823 uint64_t ms_entries;
2824 uint64_t ms_mod_txnid;
2825};
2826#ifndef __cplusplus
2828typedef struct MDBX_stat MDBX_stat;
2829#endif
2830
2850LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes);
2851
2855MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes) {
2856 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2857}
2858
2863 struct {
2864 uint64_t lower;
2865 uint64_t upper;
2866 uint64_t current;
2867 uint64_t shrink;
2868 uint64_t grow;
2870 uint64_t mi_mapsize;
2871 uint64_t mi_dxb_fsize;
2873 uint64_t mi_last_pgno;
2878 uint32_t mi_maxreaders;
2879 uint32_t mi_numreaders;
2882 uint32_t mi_sys_upcblk;
2883 uint32_t mi_sys_ioblk;
2884
2893 struct {
2894 struct {
2895 uint64_t x, y;
2896 } current, meta[3];
2898
2915 uint32_t mi_mode;
2916
2922 struct {
2923 uint64_t newly;
2924 uint64_t cow;
2925 uint64_t clone;
2927 uint64_t split;
2928 uint64_t merge;
2929 uint64_t spill;
2930 uint64_t unspill;
2931 uint64_t wops;
2933 uint64_t prefault;
2934 uint64_t mincore;
2935 uint64_t msync;
2936 uint64_t fsync;
2938
2939 /* GUID of the database DXB file. */
2940 struct {
2941 uint64_t x, y;
2943};
2944#ifndef __cplusplus
2946typedef struct MDBX_envinfo MDBX_envinfo;
2947#endif
2948
2969LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes);
2973MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes) {
2974 return mdbx_env_info_ex(env, NULL, info, bytes);
2975}
2976
3013LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
3014
3018inline int mdbx_env_sync(MDBX_env * env) { return mdbx_env_sync_ex(env, true, false); }
3019
3023inline int mdbx_env_sync_poll(MDBX_env * env) { return mdbx_env_sync_ex(env, false, true); }
3024
3048inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
3049 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
3050}
3051
3066inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
3067 int rc = MDBX_EINVAL;
3068 if (threshold) {
3069 uint64_t proxy = 0;
3070 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3071 MDBX_INLINE_API_ASSERT(proxy <= SIZE_MAX);
3072 *threshold = (size_t)proxy;
3073 }
3074 return rc;
3075}
3076
3107inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3108 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3109}
3110
3127inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3128 int rc = MDBX_EINVAL;
3129 if (period_seconds_16dot16) {
3130 uint64_t proxy = 0;
3131 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3132 MDBX_INLINE_API_ASSERT(proxy <= UINT32_MAX);
3133 *period_seconds_16dot16 = (unsigned)proxy;
3134 }
3135 return rc;
3136}
3137
3177LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3178
3182inline int mdbx_env_close(MDBX_env * env) { return mdbx_env_close_ex(env, false); }
3183
3184#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3244#endif /* Windows */
3245
3294MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3295
3296
3327 unsigned timeout_seconds_16dot16);
3328
3350
3361LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3362
3376LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3377
3378#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3383LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3384#define mdbx_env_get_pathT(env, dest) mdbx_env_get_pathW(env, dest)
3385#else
3386#define mdbx_env_get_pathT(env, dest) mdbx_env_get_path(env, dest)
3387#endif /* Windows */
3388
3402
3599LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper,
3600 intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize);
3601
3604MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3605 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3606}
3607
3623LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy);
3624
3628
3632
3637
3642
3648
3653
3659
3664
3670 MDBX_db_flags_t flags);
3671
3678
3683
3707inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3708 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3709}
3710
3722inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3723 int rc = MDBX_EINVAL;
3724 if (readers) {
3725 uint64_t proxy = 0;
3726 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3727 *readers = (unsigned)proxy;
3728 }
3729 return rc;
3730}
3731
3753inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3754 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3755}
3756
3767inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3768 int rc = MDBX_EINVAL;
3769 if (dbs) {
3770 uint64_t proxy = 0;
3771 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3772 *dbs = (MDBX_dbi)proxy;
3773 }
3774 return rc;
3775}
3776
3782
3797LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages);
3798
3809
3820
3825
3836
3848
3858
3867
3927 void *context);
3928
3983inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) {
3984 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3985}
3986
4038LIBMDBX_API int mdbx_txn_clone(const MDBX_txn *origin, MDBX_txn **in_out_clone, void *context);
4039
4050
4062
4069 uint64_t txn_id;
4070
4076
4080
4083
4087
4095
4102
4109
4112 uint64_t txn_pget;
4113};
4114#ifndef __cplusplus
4116typedef struct MDBX_txn_info MDBX_txn_info;
4117#endif
4118
4132LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt);
4133
4139
4150
4163
4171 uint32_t preparation;
4175 uint32_t audit;
4178 uint32_t write;
4181 uint32_t sync;
4183 uint32_t ending;
4185 uint32_t whole;
4187 uint32_t gc_cputime;
4188
4197 struct {
4199 uint32_t wloops;
4201 uint32_t coalescences;
4204 uint32_t wipes;
4207 uint32_t flushes;
4210 uint32_t kicks;
4211
4213 uint32_t work_counter;
4215 uint32_t work_rtime_monotonic;
4218 uint32_t work_xtime_cpu;
4220 uint32_t work_rsteps;
4222 uint32_t work_xpages;
4224 uint32_t work_majflt;
4225
4227 uint32_t self_counter;
4230 uint32_t self_rtime_monotonic;
4233 uint32_t self_xtime_cpu;
4236 uint32_t self_rsteps;
4238 uint32_t self_xpages;
4240 uint32_t self_majflt;
4242 struct {
4243 uint32_t time;
4244 uint64_t volume;
4245 uint32_t calls;
4246 } pnl_merge_work, pnl_merge_self;
4247
4248 uint32_t max_reader_lag;
4250 uint32_t max_retained_pages;
4252};
4253#ifndef __cplusplus
4256#endif
4257
4311
4347
4384
4448LIBMDBX_API int mdbx_txn_amend(MDBX_txn *read_txn, MDBX_txn **ptr_write_txn, MDBX_txn_flags_t flags, void *context);
4449
4476
4527inline int mdbx_txn_commit(MDBX_txn * txn) { return mdbx_txn_commit_ex(txn, NULL); }
4528
4541
4584inline int mdbx_txn_abort(MDBX_txn * txn) { return mdbx_txn_abort_ex(txn, NULL); }
4585
4598
4633
4666LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4667
4699LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4700
4725
4751
4763 uint64_t x, y, z, v;
4764};
4765#ifndef __cplusplus
4767typedef struct MDBX_canary MDBX_canary;
4768#endif
4769
4789
4801
4822typedef int (*MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4823
4917LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi);
4921
4940MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi,
4941 MDBX_cmp_func keycmp, MDBX_cmp_func datacmp);
4944MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4945 MDBX_dbi *dbi, MDBX_cmp_func keycmp, MDBX_cmp_func datacmp);
4946
4960LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4964
4980typedef int (*MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4981 const struct MDBX_stat *stat, MDBX_dbi dbi) MDBX_CXX17_NOEXCEPT;
4982
5001
5014
5016
5017MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
5018
5020
5021MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
5022
5023MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
5024 return UINT64_C(0x8000000000000000) + i64;
5025}
5026
5027MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
5028 return UINT32_C(0x80000000) + i32;
5029}
5030
5031
5038
5040
5042
5044
5047
5062LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes);
5063
5079LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask);
5080
5084typedef enum MDBX_dbi_state {
5094MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
5095
5096
5107LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state);
5112inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
5113 unsigned state;
5114 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
5115}
5116
5143
5155LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
5156
5193LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data);
5194
5224LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count);
5225
5255
5269typedef struct MDBX_cache_entry {
5270 uint64_t trunk_txnid;
5274 size_t offset;
5276 uint32_t length;
5278
5284 entry->offset = 0;
5285 entry->length = 0;
5286 entry->trunk_txnid = 0;
5287 entry->last_confirmed_txnid = 0;
5288}
5289
5364
5375
5401 volatile MDBX_cache_entry_t *entry);
5402
5428 MDBX_val *data, MDBX_cache_entry_t *entry);
5429
5511LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags);
5512
5557LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data,
5558 MDBX_put_flags_t flags);
5559
5562typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes);
5563
5617LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data,
5618 MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver,
5619 void *preserver_context);
5620
5646LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data);
5647
5671
5682
5693
5724
5751
5763
5795
5816
5839
5862LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count);
5863
5884inline int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind) {
5885 return mdbx_txn_release_all_cursors_ex(txn, unbind, NULL);
5886}
5887
5913
5919
5925
5937
5956LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival);
5957
5990
6004
6032typedef int (*MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) MDBX_CXX17_NOEXCEPT;
6033
6086LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func predicate, void *context,
6087 MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg);
6088
6160 MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value,
6161 MDBX_cursor_op turn_op, void *arg);
6162
6206LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit,
6207 MDBX_cursor_op op);
6208
6290
6323
6352 uint64_t *number_of_affected);
6353
6385LIBMDBX_API int mdbx_cursor_distance(const MDBX_cursor *first, const MDBX_cursor *last, intptr_t *distance,
6386 unsigned deepness);
6387
6417LIBMDBX_API int mdbx_cursor_scroll(MDBX_cursor *cursor, intptr_t amount, unsigned deepness);
6418
6457 intptr_t count, unsigned deepness);
6458
6479
6502LIBMDBX_API int mdbx_cursor_bunch_delete(MDBX_cursor *cursor, MDBX_bunch_action_t action, uint64_t *number_of_affected);
6503
6521LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count);
6522
6545LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes);
6546
6560
6573
6588
6599
6613
6638
6658LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items);
6659
6681 ptrdiff_t *distance_items);
6682
6707LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key,
6708 const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data,
6709 ptrdiff_t *distance_items);
6710
6713#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
6714
6749
6770LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment);
6771
6788 const MDBX_val *b);
6789
6793
6810 const MDBX_val *b);
6811
6815
6841typedef int (*MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid,
6842 uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6843
6856
6866
6879MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent);
6880
6900
6915
6989typedef int (*MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6990 unsigned gap, size_t space, int retry) MDBX_CXX17_NOEXCEPT;
6991
7011
7025
7031
7036LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
7037
7043
7054LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable);
7055
7056#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
7061LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta,
7062 bool writeable);
7063#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
7064 mdbx_env_open_for_recoveryW(env, pathname, target_mets, writeable)
7065#else
7066#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
7067 mdbx_env_open_for_recovery(env, pathname, target_mets, writeable)
7068#endif /* Windows */
7069
7075LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
7076
7103LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes);
7104#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
7109LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes);
7110#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfoW(pathname, info, bytes)
7111#else
7112#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfo(pathname, info, bytes)
7113#endif /* Windows */
7114
7137MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
7138
7139
7157
7175
7179typedef struct MDBX_chk_line {
7180 struct MDBX_chk_context *ctx;
7182 char *begin, *end, *out;
7184
7188typedef struct MDBX_chk_issue {
7189 struct MDBX_chk_issue *next;
7190 size_t count;
7191 const char *caption;
7193
7197typedef struct MDBX_chk_scope {
7199 struct MDBX_chk_internal *internal;
7200 const void *object;
7204 union {
7205 void *ptr;
7206 size_t number;
7207 } usr_z, usr_v, usr_o;
7209
7214typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
7215
7221 struct {
7222 size_t begin, end, amount, count;
7224};
7225
7229typedef struct MDBX_chk_table {
7231
7233#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
7235#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
7237#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
7238
7241 int id;
7242
7244 struct {
7245 size_t all, empty, broken;
7246 size_t branch, leaf;
7248 } pages;
7272
7300
7313typedef struct MDBX_chk_callbacks {
7315 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt,
7316 va_list args);
7319 void (*issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue,
7320 const char *extra_fmt, va_list extra_args);
7322 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err);
7324
7325 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number,
7326 const MDBX_val *key, const MDBX_val *value);
7327
7330
7334 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
7335 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
7336 void (*print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix);
7338
7363 const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity,
7364 unsigned timeout_seconds_16dot16);
7365
7377
7386LIBMDBX_API const char *mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer,
7387 size_t buffer_size);
7388
7396LIBMDBX_API const char *mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size);
7397
7399
7417typedef int (*MDBX_gc_iter_func)(void *ctx, const MDBX_txn *txn, uint64_t span_txnid, size_t span_pgno,
7418 size_t span_length, bool span_is_reclaimable) MDBX_CXX17_NOEXCEPT;
7419
7423typedef struct MDBX_gc_info {
7427 size_t pages_gc;
7429 struct {
7430 size_t pages;
7431 struct MDBX_chk_histogram
7434 } gc_reclaimable;
7438
7470LIBMDBX_API int mdbx_gc_info(MDBX_txn *txn, MDBX_gc_info_t *info, size_t bytes, MDBX_gc_iter_func iter_func,
7471 void *iter_ctx);
7472
7492MDBX_DEFINE_ENUM_FLAG_OPERATORS(MDBX_defrag_stopping_reasons)
7493
7494
7498typedef struct MDBX_defrag_result {
7503
7506
7509
7513
7516
7519
7523
7527
7537
7541
7543 unsigned cycles;
7544
7548
7552
7572typedef int (*MDBX_defrag_notify_func)(void *ctx, const MDBX_defrag_result_t *progress) MDBX_CXX17_NOEXCEPT;
7573
7663LIBMDBX_API int mdbx_env_defrag(MDBX_env *env, size_t defrag_atleast, size_t time_atleast_dot16, size_t defrag_enough,
7664 size_t time_limit_dot16, intptr_t acceptable_backlash, intptr_t preferred_batch,
7665 MDBX_defrag_notify_func progress_callback, void *ctx, MDBX_defrag_result_t *result);
7666
7668
7669#ifdef __cplusplus
7670} /* extern "C" */
7671#endif
7672
7673#endif /* LIBMDBX_H */
#define MDBX_INLINE_API_ASSERT(expr)
Definition mdbx.h:605
#define MDBX_NOTHROW_CONST_FUNCTION
The const nothrow function attribute for optimization.
Definition mdbx.h:315
#define MDBX_CXX17_NOEXCEPT
Definition mdbx.h:429
#define MDBX_NOTHROW_PURE_FUNCTION
The pure nothrow function attribute for optimization.
Definition mdbx.h:274
#define MDBX_NORETURN
Definition mdbx.h:499
uint64_t mi_mapsize
Definition mdbx.h:2870
uint32_t wipes
The number of previous reliable/stable committed points erased when working in MDBX_UTTERLY_NOSYNC mo...
size_t pages_scheduled
Definition mdbx.h:7508
uint64_t txn_space_dirty
Definition mdbx.h:4108
struct MDBX_envinfo::@012005163333303136244023145022271211024347140371 mi_geo
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4187
const char * describe
struct MDBX_chk_histogram pgno_distribution
uint32_t mi_dxb_pagesize
Definition mdbx.h:2880
uint32_t mi_maxreaders
Definition mdbx.h:2878
MDBX_error_t errcode
Definition mdbx.h:5371
uint64_t v
Definition mdbx.h:4763
uint64_t obstructed_txnid
Definition mdbx.h:7530
intptr_t pages_shrinked
Definition mdbx.h:7502
size_t obstructed_span
Definition mdbx.h:7526
uint32_t coalescences
The number of iterations of merging GC items.
uint32_t mi_numreaders
Definition mdbx.h:2879
uint16_t patch
Definition mdbx.h:661
const char * metadata
Definition mdbx.h:682
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2906
uint32_t length
Definition mdbx.h:5276
uint32_t self_xpages
The number of page sequences allocation requests for the GC itself.
uint16_t major
Definition mdbx.h:659
uint64_t txn_reader_lag
Definition mdbx.h:4075
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2877
MDBX_cache_status_t status
Definition mdbx.h:5373
uint64_t txn_space_leftover
Definition mdbx.h:4101
struct MDBX_envinfo::@366225332126364017271247035205240304242123014254 mi_pgop_stat
uint64_t txn_space_used
Definition mdbx.h:4079
const char * datetime
Definition mdbx.h:677
mdbx_tid_t obstructor_tid
Definition mdbx.h:7533
size_t pages_total
Definition mdbx.h:7424
uint64_t mi_recent_txnid
Definition mdbx.h:2874
size_t pages_moved
Definition mdbx.h:7505
uint64_t mi_autosync_threshold
Definition mdbx.h:2902
size_t pages_allocated
Definition mdbx.h:7426
const char * semver_prerelease
Definition mdbx.h:663
uint32_t wloops
The number of GC update iterations is greater than 1 if there were repeats/restarts.
size_t pages_gc
Definition mdbx.h:7427
uint64_t ms_branch_pages
Definition mdbx.h:2820
uint64_t ms_entries
Definition mdbx.h:2823
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4173
unsigned rough_estimation_cycle_progress_permille
Definition mdbx.h:7540
uint16_t minor
Definition mdbx.h:660
uint64_t txn_pget
Definition mdbx.h:4112
size_t offset
Definition mdbx.h:5274
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2912
uint64_t y
Definition mdbx.h:4763
size_t max_retained_pages
Definition mdbx.h:7436
size_t max_reader_lag
Definition mdbx.h:7435
uint64_t last_confirmed_txnid
Definition mdbx.h:5272
unsigned stopping_reasons
Definition mdbx.h:7547
struct MDBX_envinfo::@041066021046127331076001156004251200350305323267 mi_dxbid
uint32_t sync
Duration of syncing written data to the disk/storage, i.e. the duration of a fdatasync() or a msync()...
Definition mdbx.h:4181
uint32_t mi_sys_ioblk
Definition mdbx.h:2883
mdbx_pid_t obstructor_pid
Definition mdbx.h:7536
uint64_t txn_space_limit_soft
Definition mdbx.h:4082
uint32_t mi_mode
Definition mdbx.h:2915
size_t pages_retained
Definition mdbx.h:7512
const char * options
Definition mdbx.h:679
uint64_t txn_id
Definition mdbx.h:4069
const char * sourcery
Definition mdbx.h:670
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2875
uint64_t ms_overflow_pages
Definition mdbx.h:2822
uint32_t self_rsteps
The number of search iterations inside the GC when allocating pages for the purposes of maintaining a...
struct MDBX_envinfo::@036110245144360117333346206230046231375034327042 mi_bootid
A mostly unique ID that is regenerated on each boot.
uint32_t self_majflt
The number of page faults within the GC when allocating and preparing pages for the GC itself.
uint32_t work_majflt
The number of page faults inside the GC when allocating and preparing pages for user's data.
uint32_t preparation
Duration of preparation (commit child transactions, update table's records and cursors destroying).
Definition mdbx.h:4171
uint32_t mi_sys_upcblk
Definition mdbx.h:2882
uint64_t z
Definition mdbx.h:4763
unsigned cycles
Definition mdbx.h:7543
uint64_t txn_space_limit_hard
Definition mdbx.h:4086
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4185
uint32_t flushes
The number of forced commits to disk to avoid the database growth when working outside of MDBX_UTTERL...
uint32_t work_xpages
The number of requests to allocate page sequences for the sake of user's data.
const char * flags
Definition mdbx.h:681
uint32_t self_counter
The GC's slow path execution count is for the purposes of maintaining and updating the GC itself.
size_t pages_whole
Definition mdbx.h:7518
struct MDBX_chk_histogram span_histogram
uint32_t self_rtime_monotonic
The time "by the wall clock" spent reading and searching inside the GC for the purposes of maintainin...
struct MDBX_commit_latency::@063112077126007214166021162020057361221355030117 gc_prof
Information for GC profiling.
uint64_t mi_meta_sign[3]
Definition mdbx.h:2877
uint32_t ms_psize
Definition mdbx.h:2817
uint32_t kicks
The number of accesses to the Handle-Slow-Readers mechanism to avoid void the database growth.
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4175
size_t obstructed_pgno
Definition mdbx.h:7522
uint16_t tweak
Definition mdbx.h:662
const char * target
Definition mdbx.h:678
uint32_t write
Duration of writing dirty/modified data pages to a filesystem, i.e. the summary duration of a write()...
Definition mdbx.h:4178
uint64_t txn_space_retired
Definition mdbx.h:4094
uint32_t ms_depth
Definition mdbx.h:2819
uint64_t mi_dxb_fallocated
Definition mdbx.h:2872
uint64_t mi_last_pgno
Definition mdbx.h:2873
uint32_t work_counter
Number of slow/deep path GC search for the sake of placement user's data.
uint32_t self_xtime_cpu
The CPU time in user mode spent preparing pages taken from the GC for the purposes of maintaining and...
uint32_t ending
Duration of transaction ending (releasing resources).
Definition mdbx.h:4183
uint64_t ms_mod_txnid
Definition mdbx.h:2824
uint32_t work_rsteps
The number of search iterations inside GC when allocating pages for the sake of user's data.
size_t pages_backed
Definition mdbx.h:7425
uint64_t trunk_txnid
Definition mdbx.h:5270
const char * datetime
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2876
uint64_t ms_leaf_pages
Definition mdbx.h:2821
uint64_t mi_dxb_fsize
Definition mdbx.h:2871
uint64_t x
Definition mdbx.h:4763
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2909
uint64_t mi_unsync_volume
Definition mdbx.h:2900
uint32_t mi_sys_pagesize
Definition mdbx.h:2881
size_t pages_left
Definition mdbx.h:7515
struct MDBX_version_info::@246336125106374236367351214106016351032060025144 git
uint32_t work_rtime_monotonic
The time "by the wall clock" spent reading and searching inside the GC for the user's data.
uint32_t work_xtime_cpu
The CPU time in user mode spent for preparing pages taken from the GC for user data,...
size_t spent_time_dot16
Definition mdbx.h:7550
const char * compiler
Definition mdbx.h:680
MDBX_constants
Definition mdbx.h:810
mode_t mdbx_mode_t
Definition mdbx.h:187
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 reade...
#define LIBMDBX_API
Definition mdbx.h:633
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the table. .
Definition mdbx.h:807
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
pthread_t mdbx_tid_t
Definition mdbx.h:186
LIBMDBX_VERINFO_API const struct MDBX_build_info mdbx_build
libmdbx build information
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition mdbx.h:740
int mdbx_filehandle_t
Definition mdbx.h:184
LIBMDBX_API const char * mdbx_liberr2str(int errnum)
pid_t mdbx_pid_t
Definition mdbx.h:185
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.
#define LIBMDBX_VERINFO_API
Definition mdbx.h:654
@ MDBX_MAX_PAGESIZE
Definition mdbx.h:821
@ MDBX_MAXDATASIZE
Definition mdbx.h:815
@ MDBX_MAX_DBI
Definition mdbx.h:812
@ MDBX_MIN_PAGESIZE
Definition mdbx.h:818
libmdbx build information
Definition mdbx.h:676
Lightweight transparent cache entry structure used by mdbx_cache_get().
Definition mdbx.h:5269
Pair of error code and cache status as a result of mdbx_cache_get().
Definition mdbx.h:5369
The fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h:4762
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4168
The numerical metrics of progress and result of database defragmentation.
Definition mdbx.h:7498
Information about the environment.
Definition mdbx.h:2862
Information about Garbage Collection and page usage.
Definition mdbx.h:7423
Statistics for a table in the environment.
Definition mdbx.h:2816
Information about the transaction.
Definition mdbx.h:4066
libmdbx version information,
Definition mdbx.h:658
MDBX_bunch_action_t
Modes for deleting bunches of neighboring items with self-documenting names.
Definition mdbx.h:6466
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
LIBMDBX_API int mdbx_cursor_delete_range(MDBX_cursor *begin, MDBX_cursor *end, bool end_including, uint64_t *number_of_affected)
Quickly removes given range of items.
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
A data preservation callback for using within mdbx_replace_ex().
Definition mdbx.h:5562
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_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func predicate, void *context, MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg)
Scans the table using the passed predicate, reducing the associated overhead.
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_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.
MDBX_put_flags_t
Data changing flags.
Definition mdbx.h:1652
LIBMDBX_API MDBX_cache_result_t mdbx_cache_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, volatile MDBX_cache_entry_t *entry)
Gets items from a table using cache including multithreaded cases.
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)
Replaces item in a table using preservation callback for an original data.
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_count(const MDBX_cursor *cursor, size_t *count)
Return count values (aka duplicates) for current key.
int(* MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) noexcept
A callback function used to compare two keys in a table.
Definition mdbx.h:4822
int(* MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) noexcept
The type of predicative callback functions used by mdbx_cursor_scan() and mdbx_cursor_scan_from() to ...
Definition mdbx.h:6032
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.
MDBX_cache_status_t
Cache entry status returned by mdbx_cache_get().
Definition mdbx.h:5294
LIBMDBX_API MDBX_cache_result_t mdbx_cache_get_SingleThreaded(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_cache_entry_t *entry)
Gets items from a table using cache within single-thread cases only.
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.
void mdbx_cache_init(MDBX_cache_entry_t *entry)
Initializes the cache entry before the first use.
Definition mdbx.h:5283
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 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)
Replaces item in 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_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_bunch_delete(MDBX_cursor *cursor, MDBX_bunch_action_t action, uint64_t *number_of_affected)
Quickly removes bunches of neighboring items.
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_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_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a table.
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 int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a table.
@ MDBX_DELETE_AFTER_INCLUDING
Definition mdbx.h:6475
@ MDBX_DELETE_BEFORE_INCLUDING
Definition mdbx.h:6474
@ MDBX_DELETE_WHOLE
Definition mdbx.h:6477
@ MDBX_DELETE_BEFORE_EXCLUDING
Definition mdbx.h:6473
@ MDBX_DELETE_CURRENT_VALUE
Definition mdbx.h:6467
@ MDBX_DELETE_CURRENT_MULTIVAL_BEFORE_EXCLUDING
Definition mdbx.h:6468
@ MDBX_DELETE_AFTER_EXCLUDING
Definition mdbx.h:6476
@ MDBX_DELETE_CURRENT_MULTIVAL_ALL
Definition mdbx.h:6472
@ MDBX_DELETE_CURRENT_MULTIVAL_BEFORE_INCLUDING
Definition mdbx.h:6469
@ MDBX_DELETE_CURRENT_MULTIVAL_AFTER_INCLUDING
Definition mdbx.h:6470
@ MDBX_DELETE_CURRENT_MULTIVAL_AFTER_EXCLUDING
Definition mdbx.h:6471
@ MDBX_MULTIPLE
Definition mdbx.h:1689
@ MDBX_ALLDUPS
Definition mdbx.h:1672
@ MDBX_CURRENT
Definition mdbx.h:1667
@ MDBX_APPENDDUP
Definition mdbx.h:1685
@ MDBX_NODUPDATA
Definition mdbx.h:1661
@ MDBX_APPEND
Definition mdbx.h:1680
@ MDBX_UPSERT
Definition mdbx.h:1654
@ MDBX_RESERVE
Definition mdbx.h:1676
@ MDBX_NOOVERWRITE
Definition mdbx.h:1657
@ MDBX_CACHE_DIRTY
The result of getting a value is correct, but it cannot be cached since the changes have not been com...
Definition mdbx.h:5336
@ MDBX_CACHE_UNABLE
The result of getting a value is correct, but it cannot be cached since there the ABA-like issue is i...
Definition mdbx.h:5318
@ MDBX_CACHE_HIT
The result of getting a value is correct and was retrieved from the cache entry which is untouched.
Definition mdbx.h:5344
@ MDBX_CACHE_CONFIRMED
The result of getting a value is correct and has been retrieved from the cache, which has been altere...
Definition mdbx.h:5352
@ MDBX_CACHE_ERROR
The error other than MDBX_NOTFOUND has occurred.
Definition mdbx.h:5299
@ MDBX_CACHE_RACE
The result was obtained by bypassing the cache, because the given cache entry being updated by anothe...
Definition mdbx.h:5327
@ MDBX_CACHE_BEHIND
The result was obtained by bypassing the cache, because the transaction is too old to using the cache...
Definition mdbx.h:5307
@ MDBX_CACHE_REFRESHED
The result of getting a value is correct and corresponds to the fresh data readed from the database,...
Definition mdbx.h:5362
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Determines whether the cursor is on the first or single multi-value corresponding to the key.
LIBMDBX_API int mdbx_cursor_open(MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor)
Create a cursor handle for the specified transaction and DBI handle.
int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind)
Unbind or closes all cursors of a given transaction and of all its parent transactions if ones are.
Definition mdbx.h:5884
LIBMDBX_API int mdbx_cursor_unbind(MDBX_cursor *cursor)
Unbind cursor from a transaction.
LIBMDBX_API MDBX_cursor * mdbx_cursor_create(void *context)
Create a cursor handle but not bind it to transaction nor DBI-handle.
LIBMDBX_API MDBX_dbi mdbx_cursor_dbi(const MDBX_cursor *cursor)
Return the cursor's table handle.
MDBX_cursor_op
Cursor operationsThis is the set of all operations for retrieving data using a cursor.
Definition mdbx.h:1733
LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival)
Compares the position of the cursors.
LIBMDBX_API int mdbx_cursor_on_last_dup(const MDBX_cursor *cursor)
Determines whether the cursor is on the last or single multi-value corresponding to the key.
LIBMDBX_API int mdbx_cursor_distribute(const MDBX_cursor *first, const MDBX_cursor *last, MDBX_cursor **array, intptr_t count, unsigned deepness)
Distributes cursors for multithreaded range scanning.
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_bind(MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi)
Bind cursor to specified transaction and DBI-handle.
LIBMDBX_API int mdbx_cursor_reset(MDBX_cursor *cursor)
Resets the cursor state.
LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count)
Unbind or closes all cursors of a given transaction and of all its parent transactions if ones are.
struct MDBX_cursor MDBX_cursor
Opaque structure for navigating through a table.
Definition mdbx.h:770
LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx)
Set application information associated with the cursor.
LIBMDBX_API int mdbx_cursor_distance(const MDBX_cursor *first, const MDBX_cursor *last, intptr_t *distance, unsigned deepness)
Calculates the distance between the cursors at the specified B-tree level.
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 point...
LIBMDBX_API int mdbx_cursor_scroll(MDBX_cursor *cursor, intptr_t amount, unsigned deepness)
Scrolls the cursor to the specified number of positions at the specified B-tree level.
LIBMDBX_API int mdbx_cursor_close2(MDBX_cursor *cursor)
Closes a cursor handle with returning error code.
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_renew(MDBX_txn *txn, MDBX_cursor *cursor)
Renew a cursor handle for use within the given transaction.
LIBMDBX_API void mdbx_cursor_close(MDBX_cursor *cursor)
Closes a cursor handle without returning error code.
LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
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_copy(const MDBX_cursor *src, MDBX_cursor *dest)
Copy cursor position and state.
@ MDBX_SET_LOWERBOUND
Definition mdbx.h:1810
@ MDBX_SEEK_AND_GET_MULTIPLE
Definition mdbx.h:1852
@ MDBX_GET_CURRENT
Definition mdbx.h:1748
@ MDBX_GET_BOTH
Definition mdbx.h:1741
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1829
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1745
@ MDBX_SET_KEY
Definition mdbx.h:1788
@ MDBX_FIRST_DUP
Definition mdbx.h:1738
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1828
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1753
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1839
@ MDBX_NEXT_NODUP
Definition mdbx.h:1773
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1836
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1837
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1844
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1796
@ MDBX_SET_RANGE
Definition mdbx.h:1791
@ MDBX_LAST_DUP
Definition mdbx.h:1759
@ MDBX_PREV
Definition mdbx.h:1776
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1846
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1847
@ MDBX_LAST
Definition mdbx.h:1756
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1827
@ MDBX_PREV_DUP
Definition mdbx.h:1779
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1835
@ MDBX_SET
Definition mdbx.h:1785
@ MDBX_NEXT
Definition mdbx.h:1762
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1830
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1843
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1770
@ MDBX_PREV_NODUP
Definition mdbx.h:1782
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1845
@ MDBX_NEXT_DUP
Definition mdbx.h:1765
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1838
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1824
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1831
@ MDBX_FIRST
Definition mdbx.h:1735
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_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name)
Renames the table using the DBI descriptor.
LIBMDBX_API int mdbx_dbi_rename2(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name)
Renames the table using the DBI descriptor.
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_close(MDBX_env *env, MDBX_dbi dbi)
Close a table handle. Normally unnecessary.
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.
uint32_t MDBX_dbi
A handle for an individual table (key-value spaces) in the environment.
Definition mdbx.h:763
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1602
@ MDBX_INTEGERDUP
Definition mdbx.h:1626
@ MDBX_DB_ACCEDE
Definition mdbx.h:1644
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1604
@ MDBX_REVERSEKEY
Definition mdbx.h:1607
@ MDBX_DUPFIXED
Definition mdbx.h:1621
@ MDBX_INTEGERKEY
Definition mdbx.h:1617
@ MDBX_REVERSEDUP
Definition mdbx.h:1629
@ MDBX_CREATE
Definition mdbx.h:1632
@ MDBX_DUPSORT
Definition mdbx.h:1610
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.
LIBMDBX_API int mdbx_setup_debug(MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func logger)
Setups global log-level, debug options and logger for format string and va_list.
MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const char *msg, const char *func, unsigned line)
Auxiliary function for MDBX_INLINE_API_ASSERT().
void(* MDBX_panic_func)(const char *msg, const char *function, unsigned line, const void *obj, const char *obj_class) noexcept
A callback function for most assertion failures, that called before printing the message and aborting...
Definition mdbx.h:1056
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)
Setups global log-level, debug options, buffer and logger for plain preformatted messages.
void(* MDBX_debug_func)(MDBX_log_level_t log_level, const char *function, int line, const char *fmt, va_list args) noexcept
A log callback function that accepts a format string and arguments passed through the va_list pointer...
Definition mdbx.h:990
MDBX_log_level_t
Definition mdbx.h:883
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:941
LIBMDBX_API void mdbx_set_panic(MDBX_panic_func func)
Sets or reset the callback for panic() and assert() for the current process.
void(* MDBX_debug_func_nofmt)(MDBX_log_level_t log_level, const char *function, int line, const char *msg, unsigned length) noexcept
A log callback function that accepts a formatted message with length.
Definition mdbx.h:1018
@ MDBX_LOG_EXTRA
Definition mdbx.h:928
@ MDBX_LOG_WARN
Definition mdbx.h:902
@ MDBX_LOG_TRACE
Definition mdbx.h:923
@ MDBX_LOG_DEBUG
Definition mdbx.h:918
@ MDBX_LOG_FATAL
Definition mdbx.h:890
@ MDBX_LOG_ERROR
Definition mdbx.h:896
@ MDBX_LOG_NOTICE
Definition mdbx.h:908
@ MDBX_LOG_MAX
Definition mdbx.h:931
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:885
@ MDBX_LOG_VERBOSE
Definition mdbx.h:913
@ MDBX_DBG_ASSERT
Definition mdbx.h:949
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:972
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:968
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:965
@ MDBX_DBG_NONE
Definition mdbx.h:945
@ MDBX_DBG_DUMP
Definition mdbx.h:962
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:943
@ MDBX_DBG_AUDIT
Definition mdbx.h:954
@ MDBX_DBG_JITTER
Definition mdbx.h:958
@ MDBX_DBG_MAX
Definition mdbx.h:975
LIBMDBX_API const char * mdbx_strerror(int errnum)
Return a string describing a given error code.
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1860
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 ...
LIBMDBX_API const char * mdbx_strerror_r(int errnum, char *buf, size_t buflen)
Return a string describing a given error code.
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) wh...
Definition mdbx.h:6989
LIBMDBX_API const char * mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen)
@ MDBX_PANIC
Definition mdbx.h:1887
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1874
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1973
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1921
@ MDBX_EACCESS
Definition mdbx.h:2033
@ MDBX_EIO
Definition mdbx.h:2041
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1880
@ MDBX_TXN_FULL
Definition mdbx.h:1905
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1890
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1970
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1984
@ MDBX_EREMOTE
Definition mdbx.h:2048
@ MDBX_TOO_LARGE
Definition mdbx.h:1977
@ MDBX_EBADSIGN
Definition mdbx.h:1966
@ MDBX_CURSOR_FULL
Definition mdbx.h:1909
@ MDBX_ENOFILE
Definition mdbx.h:2045
@ MDBX_BAD_TXN
Definition mdbx.h:1937
@ MDBX_ENODATA
Definition mdbx.h:2028
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1951
@ MDBX_CORRUPTED
Definition mdbx.h:1883
@ MDBX_EPERM
Definition mdbx.h:2042
@ MDBX_EEXIST
Definition mdbx.h:2044
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1981
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1989
@ MDBX_SUCCESS
Definition mdbx.h:1862
@ MDBX_NOTFOUND
Definition mdbx.h:1877
@ MDBX_LAGGARD_READER
Definition mdbx.h:2007
@ MDBX_RESULT_TRUE
Definition mdbx.h:1868
@ MDBX_INVALID
Definition mdbx.h:1893
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1941
@ MDBX_BUSY
Definition mdbx.h:1955
@ MDBX_OUSTED
Definition mdbx.h:2000
@ MDBX_DBS_FULL
Definition mdbx.h:1899
@ MDBX_EINVAL
Definition mdbx.h:2032
@ MDBX_BAD_RSLOT
Definition mdbx.h:1932
@ MDBX_ENOMEM
Definition mdbx.h:2034
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1958
@ MDBX_RESULT_FALSE
Definition mdbx.h:1865
@ MDBX_DUPLICATED_LCK
Definition mdbx.h:1992
@ MDBX_EINTR
Definition mdbx.h:2043
@ MDBX_READERS_FULL
Definition mdbx.h:1902
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:2010
@ MDBX_BAD_DBI
Definition mdbx.h:1945
@ MDBX_KEYEXIST
Definition mdbx.h:1871
@ MDBX_DANGLING_DBI
Definition mdbx.h:1996
@ MDBX_EDEADLK
Definition mdbx.h:2052
@ MDBX_PAGE_FULL
Definition mdbx.h:1912
@ MDBX_MAP_FULL
Definition mdbx.h:1896
@ MDBX_PROBLEM
Definition mdbx.h:1948
@ MDBX_ENOSYS
Definition mdbx.h:2037
@ MDBX_EMULTIVAL
Definition mdbx.h:1961
@ MDBX_EROFS
Definition mdbx.h:2035
@ MDBX_MVCC_RETARDED
Definition mdbx.h:2003
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1929
LIBMDBX_API int mdbx_reader_check(MDBX_env *env, int *dead)
Check for stale entries in the reader lock table.
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.
MDBX_copy_flags_t
Environment copy flags.
Definition mdbx.h:1696
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_env_chk_encount_problem(MDBX_chk_context_t *ctx)
An auxiliary function to account issues detected by an application, including those coming to an appl...
int mdbx_env_sync(MDBX_env *env)
The shortcut to calling mdbx_env_sync_ex() with the force=true and nonblock=false arguments.
Definition mdbx.h:3018
int(* MDBX_defrag_notify_func)(void *ctx, const MDBX_defrag_result_t *progress) noexcept
A callback function to notify an application about the progress of defragmentation.
Definition mdbx.h:7572
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)
Checks the integrity of a database.
LIBMDBX_API const char * mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer, size_t buffer_size)
An auxiliary function for converting fractions to string of decimal digits without using floating-poi...
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 availabl...
LIBMDBX_API int mdbx_thread_register(const MDBX_env *env)
Registers the current thread as a reader for the environment.
MDBX_chk_stage_t
The verification stages reported via callbacks during a database integrity check.
Definition mdbx.h:7161
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
int mdbx_env_sync_poll(MDBX_env *env)
The shortcut to calling mdbx_env_sync_ex() with the force=false and nonblock=true arguments.
Definition mdbx.h:3023
LIBMDBX_API const char * mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size)
An auxiliary function for converting fractions to percentage string without using floating-point oper...
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
A custom type for binding additional data associated with a certain key-value table during a database...
Definition mdbx.h:7214
LIBMDBX_API int mdbx_env_defrag(MDBX_env *env, size_t defrag_atleast, size_t time_atleast_dot16, size_t defrag_enough, size_t time_limit_dot16, intptr_t acceptable_backlash, intptr_t preferred_batch, MDBX_defrag_notify_func progress_callback, void *ctx, MDBX_defrag_result_t *result)
Performs database defragmentation.
MDBX_chk_flags_t
Flags/options for checking the integrity of a database.
Definition mdbx.h:7119
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 MDBX_cmp_func mdbx_get_keycmp(MDBX_db_flags_t flags)
Returns default internal key's comparator for given table flags.
MDBX_chk_severity_t
Levels of logging/detailing of information supplied via callbacks during a database integrity check.
Definition mdbx.h:7142
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_env_resurrect_after_fork(MDBX_env *env)
Restores an instance of the environment in a child process after forking the parent process using for...
MDBX_env_delete_mode_t
Deletion modes for mdbx_env_delete().
Definition mdbx.h:2584
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.
MDBX_defrag_stopping_reasons_t
The returned reasons for stopping database defragmentation.
Definition mdbx.h:7478
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_cursor_ignord(MDBX_cursor *cursor)
An auxiliary function for use in tools.
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_thread_unregister(const MDBX_env *env)
Unregisters the current thread as a reader for the environment.
LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock)
Flush the environment data buffers to disk.
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_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_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_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.
@ MDBX_CP_DISPOSE_TXN
Definition mdbx.h:1715
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1697
@ MDBX_CP_COMPACT
Definition mdbx.h:1701
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1720
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1711
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1704
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1707
@ MDBX_CP_OVERWRITE
Definition mdbx.h:1724
@ MDBX_chk_gc
Definition mdbx.h:7167
@ MDBX_chk_init
Definition mdbx.h:7163
@ MDBX_chk_finalize
Definition mdbx.h:7173
@ MDBX_chk_space
Definition mdbx.h:7168
@ MDBX_chk_lock
Definition mdbx.h:7164
@ MDBX_chk_none
Definition mdbx.h:7162
@ MDBX_chk_maindb
Definition mdbx.h:7169
@ MDBX_chk_unlock
Definition mdbx.h:7172
@ MDBX_chk_meta
Definition mdbx.h:7165
@ MDBX_chk_conclude
Definition mdbx.h:7171
@ MDBX_chk_tree
Definition mdbx.h:7166
@ MDBX_chk_tables
Definition mdbx.h:7170
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:7127
@ MDBX_CHK_READWRITE
Definition mdbx.h:7124
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:7121
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:7130
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:7135
@ MDBX_chk_processing
Definition mdbx.h:7151
@ MDBX_chk_result
Definition mdbx.h:7149
@ MDBX_chk_details
Definition mdbx.h:7154
@ MDBX_chk_extra
Definition mdbx.h:7155
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:7143
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:7144
@ MDBX_chk_notice
Definition mdbx.h:7148
@ MDBX_chk_resolution
Definition mdbx.h:7150
@ MDBX_chk_warning
Definition mdbx.h:7147
@ MDBX_chk_fatal
Definition mdbx.h:7145
@ MDBX_chk_info
Definition mdbx.h:7152
@ MDBX_chk_error
Definition mdbx.h:7146
@ MDBX_chk_verbose
Definition mdbx.h:7153
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2596
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2591
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2594
@ MDBX_defrag_time_limit
Definition mdbx.h:7488
@ MDBX_defrag_enough_threshold
Definition mdbx.h:7487
@ MDBX_defrag_error
Definition mdbx.h:7490
@ MDBX_defrag_laggard_reader
Definition mdbx.h:7485
@ MDBX_defrag_aborted
Definition mdbx.h:7489
@ MDBX_defrag_noobstacles
Definition mdbx.h:7479
@ MDBX_defrag_discontinued
Definition mdbx.h:7484
@ MDBX_defrag_large_chunk
Definition mdbx.h:7481
@ MDBX_defrag_step_size
Definition mdbx.h:7480
LIBMDBX_API int mdbx_env_create(MDBX_env **penv)
Create an MDBX environment instance.
int mdbx_env_close(MDBX_env *env)
The shortcut to calling mdbx_env_close_ex() with the dont_sync=false argument.
Definition mdbx.h:3182
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1084
LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync)
Close the environment and release the memory map.
LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes)
Gets basic information about the database without opening it.
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_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes)
Gets basic information about the database without opening it.
@ MDBX_NORDAHEAD
Definition mdbx.h:1275
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1085
@ MDBX_NOMETASYNC
Definition mdbx.h:1397
@ MDBX_LIFORECLAIM
Definition mdbx.h:1322
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1448
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1379
@ MDBX_PAGEPERTURB
Definition mdbx.h:1325
@ MDBX_WRITEMAP
Definition mdbx.h:1204
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1254
@ MDBX_EXCLUSIVE
Definition mdbx.h:1158
@ MDBX_NOMEMINIT
Definition mdbx.h:1298
@ MDBX_ACCEDE
Definition mdbx.h:1173
@ MDBX_NOSUBDIR
Definition mdbx.h:1110
@ MDBX_RDONLY
Definition mdbx.h:1128
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1491
@ MDBX_VALIDATION
Definition mdbx.h:1092
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.
int mdbx_env_set_mapsize(MDBX_env *env, size_t size)
Definition mdbx.h:3604
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3753
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_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue)
Gets the value of extra runtime options from an 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,...
Definition mdbx.h:3107
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2136
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 memor...
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 envi...
Definition mdbx.h:3048
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3250
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_set_userctx(MDBX_env *env, void *ctx)
Sets application information (a context pointer) associated with the environment.
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.
Definition mdbx.h:3707
LIBMDBX_API int mdbx_env_set_flags(MDBX_env *env, MDBX_env_flags_t flags, bool onoff)
Set environment flags.
@ MDBX_opt_txn_dp_initial
Controls the in-process initial allocation size for dirty pages list of a write transaction....
Definition mdbx.h:2241
@ MDBX_opt_subpage_room_threshold
Sets the minimum amount of free space on a leaf page in the absence of which the nested pages are pla...
Definition mdbx.h:2403
@ MDBX_opt_subpage_limit
Specifies the maximum size of nested pages used to accommodate a small number of multi-values associa...
Definition mdbx.h:2396
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2237
@ MDBX_opt_prefer_waf_insteadof_balance
Controls the choice between striving for uniformity of page filling/density, either for reducing the ...
Definition mdbx.h:2382
@ MDBX_opt_presync_threshold
Sets threshold in bytes for preliminary flush/sync operation without holding a transaction lock.
Definition mdbx.h:2463
@ MDBX_opt_prefault_write_enable
Controls prevention of page-faults of reclaimed and allocated pages in the MDBX_WRITEMAP mode by clea...
Definition mdbx.h:2341
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2145
@ MDBX_opt_subpage_reserve_prereq
Sets the minimum amount of free space on the main page, if available, to reserve space in the subpage...
Definition mdbx.h:2417
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2168
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2273
@ MDBX_opt_spill_parent4child_denominator
Controls the in-process how much of the parent transaction dirty pages will be spilled while start ea...
Definition mdbx.h:2296
@ MDBX_opt_split_reserve
Sets the space reservation in 1/65536 of page size when splitting page along the edge.
Definition mdbx.h:2445
@ MDBX_opt_loose_limit
Controls the in-process limit to grow a cache of dirty pages for reuse in the current transaction.
Definition mdbx.h:2208
@ MDBX_opt_rp_augment_limit
Controls the in-process limit to grow a list of reclaimed/recycled page's numbers for finding a seque...
Definition mdbx.h:2195
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2162
@ MDBX_opt_subpage_reserve_limit
Sets the limit for reserving space on nested pages.
Definition mdbx.h:2423
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2257
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2174
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2222
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2336
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2360
@ MDBX_opt_merge_threshold
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2308
@ MDBX_warmup_touchlimit
Definition mdbx.h:3289
@ MDBX_warmup_force
Definition mdbx.h:3259
@ MDBX_warmup_oomsafe
Definition mdbx.h:3266
@ MDBX_warmup_release
Definition mdbx.h:3292
@ MDBX_warmup_lock
Definition mdbx.h:3281
@ MDBX_warmup_default
Definition mdbx.h:3253
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_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes)
Retrieve statistics for a table.
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 uint64_t mdbx_txn_id(const MDBX_txn *txn)
Return the transaction's ID.
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 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_get_maxreaders(const MDBX_env *env, unsigned *readers)
Get the maximum number of threads/reader slots for the environment.
Definition mdbx.h:3722
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,...
Definition mdbx.h:3127
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_txn_straggler(const MDBX_txn *txn, int *percent)
Returns a lag of the reading for the given transaction.
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_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes)
Return statistics about the MDBX environment.
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.
Definition mdbx.h:5112
LIBMDBX_API int mdbx_gc_info(MDBX_txn *txn, MDBX_gc_info_t *info, size_t bytes, MDBX_gc_iter_func iter_func, void *iter_ctx)
Provides information of Garbage Collection and page usage.
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 intptr_t mdbx_limits_valsize_min(MDBX_db_flags_t flags)
Returns minimal data size in bytes for given table flags.
int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes)
Return information about the MDBX environment.
Definition mdbx.h:2973
int(* MDBX_gc_iter_func)(void *ctx, const MDBX_txn *txn, uint64_t span_txnid, size_t span_pgno, size_t span_length, bool span_is_reclaimable) noexcept
A callback function for iterating GC entries.
Definition mdbx.h:7417
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 envir...
Definition mdbx.h:3066
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...
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 gi...
intptr_t mdbx_limits_pgsize_max(void)
Returns the maximal database page size in bytes.
Definition mdbx.h:3631
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_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt)
Return information about the MDBX transaction.
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.
MDBX_dbi_state_t
DBI state bits returted by mdbx_dbi_flags_ex().
Definition mdbx.h:5084
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 ...
intptr_t mdbx_limits_pgsize_min(void)
Returns the minimal database page size in bytes.
Definition mdbx.h:3627
LIBMDBX_API int mdbx_env_get_maxkeysize(const MDBX_env *env)
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_enumerate_tables(const MDBX_txn *txn, MDBX_table_enum_func func, void *ctx)
Enumerates user's named tables in a database.
LIBMDBX_API void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs)
Get the maximum number of named tables for the environment.
Definition mdbx.h:3767
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 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 size_t mdbx_default_pagesize(void)
Returns the default size of database page for the current system.
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
A callback function for listing user's named tables.
Definition mdbx.h:4980
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 ...
int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes)
Return statistics about the MDBX environment.
Definition mdbx.h:2855
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,...
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_dbsize_min(intptr_t pagesize)
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags)
Get environment flags.
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.
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.
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.
Definition mdbx.h:6841
@ MDBX_DBI_DIRTY
Definition mdbx.h:5086
@ MDBX_DBI_FRESH
Definition mdbx.h:5090
@ MDBX_DBI_STALE
Definition mdbx.h:5088
@ MDBX_DBI_CREAT
Definition mdbx.h:5092
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken to prevent further operations.
LIBMDBX_API int mdbx_txn_set_userctx(MDBX_txn *txn, void *ctx)
Sets application information associated (a context pointer) with the transaction.
LIBMDBX_API int mdbx_txn_clone(const MDBX_txn *origin, MDBX_txn **in_out_clone, void *context)
Starts a read-only clone of a given transaction.
LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark)
Puts the reading transaction in a "parked" state.
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.
LIBMDBX_API int mdbx_txn_refresh(MDBX_txn *txn)
Refresh a read-only transaction for a recent data.
int mdbx_txn_commit(MDBX_txn *txn)
Commits all the operations of the transaction into the database.
Definition mdbx.h:4527
LIBMDBX_API int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency)
Commits all changes of the transaction into a database with collecting latencies information.
LIBMDBX_API int mdbx_txn_rollback(MDBX_txn *txn)
Rolls back all uncommitted changes within the write transaction and keeps it running.
LIBMDBX_API int mdbx_txn_abort_ex(MDBX_txn *txn, MDBX_commit_latency *latency)
Abandons all the operations of the transaction instead of saving ones with collecting latencies infor...
LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
LIBMDBX_API int mdbx_txn_checkpoint(MDBX_txn *txn, MDBX_txn_flags_t weakening_durability, MDBX_commit_latency *latency)
Commits all the operations of the transaction and immediately starts next without releasing any locks...
LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted)
Unparks a previously parked reading transaction.
MDBX_txn_flags_t
Definition mdbx.h:1501
LIBMDBX_API void * mdbx_txn_get_userctx(const MDBX_txn *txn)
Returns an application information (a context pointer) associated with the transaction.
int mdbx_txn_abort(MDBX_txn *txn)
Abandons all the operations of the transaction instead of saving ones.
Definition mdbx.h:4584
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.
Definition mdbx.h:3983
LIBMDBX_API int mdbx_txn_amend(MDBX_txn *read_txn, MDBX_txn **ptr_write_txn, MDBX_txn_flags_t flags, void *context)
Starts a writing transaction to amending data in the MVCC-snapshot used by the read-only transaction.
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition mdbx.h:751
LIBMDBX_API int mdbx_txn_commit_embark_read(MDBX_txn **ptxn, MDBX_commit_latency *latency)
Commits all the operations of the transaction and immediately starts read transaction before release ...
LIBMDBX_API int mdbx_txn_reset(MDBX_txn *txn)
Reset a read-only transaction.
LIBMDBX_API int mdbx_txn_renew(MDBX_txn *txn)
Renew a read-only transaction.
LIBMDBX_API MDBX_txn_flags_t mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
@ MDBX_TXN_RDONLY
Definition mdbx.h:1512
@ MDBX_TXN_ERROR
Definition mdbx.h:1555
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1534
@ MDBX_TXN_SPILLS
Definition mdbx.h:1565
@ MDBX_TXN_OUSTED
Definition mdbx.h:1589
@ MDBX_TXN_NOWEAKING
Definition mdbx.h:1530
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1570
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1521
@ MDBX_TXN_INVALID
Definition mdbx.h:1545
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1594
@ MDBX_TXN_PARKED
Definition mdbx.h:1575
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1538
@ MDBX_TXN_DIRTY
Definition mdbx.h:1560
@ MDBX_TXN_READWRITE
Definition mdbx.h:1506
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1582
@ MDBX_TXN_TRY
Definition mdbx.h:1527
@ MDBX_TXN_FINISHED
Definition mdbx.h:1550
MDBX_chk_severity_t verbosity
Definition mdbx.h:7202
MDBX_txn * txn
Definition mdbx.h:7279
void(* issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue, const char *extra_fmt, va_list extra_args)
Definition mdbx.h:7319
struct MDBX_chk_histogram tree_density
struct MDBX_chk_histogram::@167152105014034103340112155364354016331236072167 ranges[9]
void(* print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix)
Definition mdbx.h:7336
void(* print_done)(MDBX_chk_line_t *)
Definition mdbx.h:7333
struct MDBX_chk_internal * internal
Definition mdbx.h:7277
uint8_t scope_nesting
Definition mdbx.h:7281
char * end
Definition mdbx.h:7182
uint8_t scope_depth
Definition mdbx.h:7181
struct MDBX_chk_histogram key_len
struct MDBX_chk_histogram large_or_nested_density
int(* stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t)
Definition mdbx.h:7328
int(* stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err)
Definition mdbx.h:7329
int(* table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err)
Definition mdbx.h:7322
void(* print_format)(MDBX_chk_line_t *, const char *fmt, va_list args)
Definition mdbx.h:7335
struct MDBX_chk_histogram histogram_pgno_payload
struct MDBX_chk_internal * internal
Definition mdbx.h:7199
char * begin
Definition mdbx.h:7182
size_t le1_count
Definition mdbx.h:7220
int(* scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt, va_list args)
Definition mdbx.h:7315
struct MDBX_chk_histogram histogram_pgno_retained
size_t subtotal_issues
Definition mdbx.h:7203
uint8_t severity
Definition mdbx.h:7181
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:7230
void(* scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner)
Definition mdbx.h:7318
struct MDBX_chk_histogram pgno
struct MDBX_chk_context * ctx
Definition mdbx.h:7180
MDBX_db_flags_t flags
Definition mdbx.h:7240
int(* scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, int err)
Definition mdbx.h:7317
size_t le1_amount
Definition mdbx.h:7220
void(* print_flush)(MDBX_chk_line_t *)
Definition mdbx.h:7332
struct MDBX_chk_issue * next
Definition mdbx.h:7189
struct MDBX_chk_histogram large_pages
char * out
Definition mdbx.h:7182
struct MDBX_chk_histogram val_len
void(* print_chars)(MDBX_chk_line_t *, const char *str, size_t len)
Definition mdbx.h:7334
const MDBX_chk_table_t *const * tables
const void * object
Definition mdbx.h:7200
size_t count
Definition mdbx.h:7220
const char * caption
Definition mdbx.h:7191
MDBX_chk_stage_t stage
Definition mdbx.h:7201
struct MDBX_chk_histogram histogram_page_age
struct MDBX_chk_histogram height
struct MDBX_chk_histogram multival
struct MDBX_chk_histogram nested_height_or_gc_span_length
MDBX_env * env
Definition mdbx.h:7278
uint8_t empty
Definition mdbx.h:7181
size_t amount
Definition mdbx.h:7220
MDBX_chk_scope_t * scope
Definition mdbx.h:7280
MDBX_chk_issue_t * issues
Definition mdbx.h:7198
size_t payload_bytes
Definition mdbx.h:7243
size_t count
Definition mdbx.h:7190
MDBX_val name
Definition mdbx.h:7239
size_t lost_bytes
Definition mdbx.h:7243
bool(* check_break)(MDBX_chk_context_t *ctx)
Definition mdbx.h:7314
void(* table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table)
Definition mdbx.h:7323
int(* table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number, const MDBX_val *key, const MDBX_val *value)
Definition mdbx.h:7325
int id
Definition mdbx.h:7241
struct MDBX_chk_histogram page_age
LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta)
Turn database to the specified meta-page.
A set of callback functions used for checking the integrity of a database.
Definition mdbx.h:7313
The context for checking the integrity of a database.
Definition mdbx.h:7276
A histogram with some statistical information collected during a database integrity check.
Definition mdbx.h:7219
An issue problem was discovered during a database integrity check.
Definition mdbx.h:7188
A virtual row of the report generated during a database integrity check.
Definition mdbx.h:7179
A hierarchical context during a database integrity check.
Definition mdbx.h:7197
Information about a certain key-value table during a database integrity check.
Definition mdbx.h:7229
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 double mdbx_double_from_key(const MDBX_val)
LIBMDBX_API int64_t mdbx_jsonInteger_from_key(const MDBX_val)
uint64_t mdbx_key_from_int64(const int64_t i64)
Definition mdbx.h:5023
LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit)
LIBMDBX_API uint64_t mdbx_key_from_double(const double ieee754_64bit)
LIBMDBX_API uint32_t mdbx_key_from_float(const float ieee754_32bit)
LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit)
uint32_t mdbx_key_from_int32(const int32_t i32)
Definition mdbx.h:5027
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)