libmdbx 0.14.1.69 (2025-08-05T13:33:47+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#ifndef LIBMDBX_H
40#define LIBMDBX_H
41
42#if defined(__riscv) || defined(__riscv__) || defined(__RISCV) || defined(__RISCV__)
43#warning "The RISC-V architecture is intentionally insecure by design. \
44 Please delete this admonition at your own risk, \
45 if you make such decision informed and consciously. \
46 Refer to https://clck.ru/32d9xH for more information."
47#endif /* RISC-V */
48
49#ifdef _MSC_VER
50#pragma warning(push, 1)
51#pragma warning(disable : 4548) /* expression before comma has no effect; \
52 expected expression with side - effect */
53#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
54 * semantics are not enabled. Specify /EHsc */
55#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
56 * mode specified; termination on exception is \
57 * not guaranteed. Specify /EHsc */
58#endif /* _MSC_VER (warnings) */
59
60/* *INDENT-OFF* */
61/* clang-format off */
144/* *INDENT-ON* */
145/* clang-format on */
146
147#include <stdarg.h>
148#include <stddef.h>
149#include <stdint.h>
150#if !defined(NDEBUG) && !defined(assert)
151#include <assert.h>
152#endif /* NDEBUG */
153
154#if defined(_WIN32) || defined(_WIN64)
155#include <windows.h>
156#include <winnt.h>
157#ifndef __mode_t_defined
158typedef unsigned short mdbx_mode_t;
159#else
160typedef mode_t mdbx_mode_t;
161#endif /* __mode_t_defined */
162typedef HANDLE mdbx_filehandle_t;
163typedef DWORD mdbx_pid_t;
164typedef DWORD mdbx_tid_t;
165#else /* Windows */
166#include <errno.h> /* for error codes */
167#include <pthread.h> /* for pthread_t */
168#include <sys/types.h> /* for pid_t */
169#include <sys/uio.h> /* for struct iovec */
170#define HAVE_STRUCT_IOVEC 1
172typedef pid_t mdbx_pid_t;
173typedef pthread_t mdbx_tid_t;
174typedef mode_t mdbx_mode_t;
175#endif /* !Windows */
176
177#ifdef _MSC_VER
178#pragma warning(pop)
179#endif
180
185
186/*----------------------------------------------------------------------------*/
187
188#ifndef __has_attribute
189#define __has_attribute(x) (0)
190#endif /* __has_attribute */
191
192#ifndef __has_c_attribute
193#define __has_c_attribute(x) (0)
194#define __has_c_attribute_qualified(x) 0
195#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
196#define __has_c_attribute_qualified(x) 0
197#elif defined(_MSC_VER)
198/* MSVC don't support `namespace::attr` syntax */
199#define __has_c_attribute_qualified(x) 0
200#else
201#define __has_c_attribute_qualified(x) __has_c_attribute(x)
202#endif /* __has_c_attribute */
203
204#ifndef __has_cpp_attribute
205#define __has_cpp_attribute(x) 0
206#define __has_cpp_attribute_qualified(x) 0
207#elif defined(_MSC_VER) || (__clang__ && __clang__ < 14)
208/* MSVC don't support `namespace::attr` syntax */
209#define __has_cpp_attribute_qualified(x) 0
210#else
211#define __has_cpp_attribute_qualified(x) __has_cpp_attribute(x)
212#endif /* __has_cpp_attribute */
213
214#ifndef __has_C23_or_CXX_attribute
215#if defined(__cplusplus)
216#define __has_C23_or_CXX_attribute(x) __has_cpp_attribute_qualified(x)
217#else
218#define __has_C23_or_CXX_attribute(x) __has_c_attribute_qualified(x)
219#endif
220#endif /* __has_C23_or_CXX_attribute */
221
222#ifndef __has_feature
223#define __has_feature(x) (0)
224#define __has_exceptions_disabled (0)
225#elif !defined(__has_exceptions_disabled)
226#define __has_exceptions_disabled (__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions))
227#endif /* __has_feature */
228
229#ifndef __has_extension
230#define __has_extension(x) __has_feature(x)
231#endif /* __has_extension */
232
233#ifndef __has_builtin
234#define __has_builtin(x) (0)
235#endif /* __has_builtin */
236
243#if defined(DOXYGEN)
244#define MDBX_PURE_FUNCTION [[gnu::pure]]
245#elif __has_C23_or_CXX_attribute(gnu::pure)
246#define MDBX_PURE_FUNCTION [[gnu::pure]]
247#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
248 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
249 __has_exceptions_disabled)
250#define MDBX_PURE_FUNCTION __attribute__((__pure__))
251#else
252#define MDBX_PURE_FUNCTION
253#endif /* MDBX_PURE_FUNCTION */
254
258#if defined(DOXYGEN)
259#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
260#elif __has_C23_or_CXX_attribute(gnu::pure)
261#if __has_C23_or_CXX_attribute(gnu::nothrow)
262#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
263#else
264#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
265#endif
266#elif defined(__GNUC__) || (__has_attribute(__pure__) && __has_attribute(__nothrow__))
267#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
268#elif __has_cpp_attribute(pure)
269#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
270#else
271#define MDBX_NOTHROW_PURE_FUNCTION
272#endif /* MDBX_NOTHROW_PURE_FUNCTION */
273
284#if defined(DOXYGEN)
285#define MDBX_CONST_FUNCTION [[gnu::const]]
286#elif __has_C23_or_CXX_attribute(gnu::const)
287#define MDBX_CONST_FUNCTION [[gnu::const]]
288#elif (defined(__GNUC__) || __has_attribute(__const__)) && \
289 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
290 __has_exceptions_disabled)
291#define MDBX_CONST_FUNCTION __attribute__((__const__))
292#else
293#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
294#endif /* MDBX_CONST_FUNCTION */
295
299#if defined(DOXYGEN)
300#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
301#elif __has_C23_or_CXX_attribute(gnu::const)
302#if __has_C23_or_CXX_attribute(gnu::nothrow)
303#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
304#else
305#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const]]
306#endif
307#elif defined(__GNUC__) || (__has_attribute(__const__) && __has_attribute(__nothrow__))
308#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
309#elif __has_cpp_attribute_qualified(const)
310#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
311#else
312#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
313#endif /* MDBX_NOTHROW_CONST_FUNCTION */
314
318#ifndef MDBX_DEPRECATED
319#ifdef __deprecated
320#define MDBX_DEPRECATED __deprecated
321#elif defined(DOXYGEN) || ((!defined(__GNUC__) || (defined(__clang__) && __clang__ > 19) || __GNUC__ > 5) && \
322 ((defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
323 __has_cpp_attribute(deprecated) >= 201309L) || \
324 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202304L)))
325#define MDBX_DEPRECATED [[deprecated]]
326#elif (defined(__GNUC__) && __GNUC__ > 5) || \
327 (__has_attribute(__deprecated__) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 5))
328#define MDBX_DEPRECATED __attribute__((__deprecated__))
329#elif defined(_MSC_VER)
330#define MDBX_DEPRECATED __declspec(deprecated)
331#else
332#define MDBX_DEPRECATED
333#endif
334#endif /* MDBX_DEPRECATED */
335
336#ifndef MDBX_DEPRECATED_ENUM
337#ifdef __deprecated_enum
338#define MDBX_DEPRECATED_ENUM __deprecated_enum
339#elif defined(DOXYGEN) || \
340 (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
341 __has_cpp_attribute(deprecated) >= 201309L))
342#define MDBX_DEPRECATED_ENUM MDBX_DEPRECATED
343#else
344#define MDBX_DEPRECATED_ENUM /* avoid madness MSVC */
345#endif
346#endif /* MDBX_DEPRECATED_ENUM */
347
348#ifndef __dll_export
349#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
350 defined(__MINGW64__)
351#if defined(__GNUC__) || __has_attribute(__dllexport__)
352#define __dll_export __attribute__((__dllexport__))
353#elif defined(_MSC_VER)
354#define __dll_export __declspec(dllexport)
355#else
356#define __dll_export
357#endif
358#elif defined(__GNUC__) || __has_attribute(__visibility__)
359#define __dll_export __attribute__((__visibility__("default")))
360#else
361#define __dll_export
362#endif
363#endif /* __dll_export */
364
365#ifndef __dll_import
366#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
367 defined(__MINGW64__)
368#if defined(__GNUC__) || __has_attribute(__dllimport__)
369#define __dll_import __attribute__((__dllimport__))
370#elif defined(_MSC_VER)
371#define __dll_import __declspec(dllimport)
372#else
373#define __dll_import
374#endif
375#else
376#define __dll_import
377#endif
378#endif /* __dll_import */
379
384#if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
385#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
386 /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
387 /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
388#else
389#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
390#endif /* LIBMDBX_INLINE_API */
391
393#ifndef MDBX_STRINGIFY
394#define MDBX_STRINGIFY_HELPER(x) #x
395#define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
396#endif /* MDBX_STRINGIFY */
397
398/*----------------------------------------------------------------------------*/
399
400#ifndef __cplusplus
401#ifndef bool
402#define bool _Bool
403#endif
404#ifndef true
405#define true (1)
406#endif
407#ifndef false
408#define false (0)
409#endif
410#endif /* bool without __cplusplus */
411
413#if defined(DOXYGEN)
414#define MDBX_CXX17_NOEXCEPT noexcept
415#elif !defined(__cpp_noexcept_function_type) || __cpp_noexcept_function_type < 201510L
416#define MDBX_CXX17_NOEXCEPT
417#else
418#define MDBX_CXX17_NOEXCEPT noexcept
419#endif /* MDBX_CXX17_NOEXCEPT */
420
422#if defined(DOXYGEN)
423#define MDBX_CXX01_CONSTEXPR constexpr
424#define MDBX_CXX01_CONSTEXPR_VAR constexpr
425#elif !defined(__cplusplus)
426#define MDBX_CXX01_CONSTEXPR __inline
427#define MDBX_CXX01_CONSTEXPR_VAR const
428#elif !defined(DOXYGEN) && \
429 ((__cplusplus < 201103L && defined(__cpp_constexpr) && __cpp_constexpr < 200704L) || \
430 (defined(__LCC__) && __LCC__ < 124) || \
431 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
432 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4))
433#define MDBX_CXX01_CONSTEXPR inline
434#define MDBX_CXX01_CONSTEXPR_VAR const
435#else
436#define MDBX_CXX01_CONSTEXPR constexpr
437#define MDBX_CXX01_CONSTEXPR_VAR constexpr
438#endif /* MDBX_CXX01_CONSTEXPR */
439
442#if defined(DOXYGEN)
443#define MDBX_CXX11_CONSTEXPR constexpr
444#define MDBX_CXX11_CONSTEXPR_VAR constexpr
445#elif !defined(__cplusplus)
446#define MDBX_CXX11_CONSTEXPR __inline
447#define MDBX_CXX11_CONSTEXPR_VAR const
448#elif !defined(DOXYGEN) && \
449 (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || (defined(__LCC__) && __LCC__ < 124) || \
450 (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && !defined(__LCC__)) || \
451 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 5))
452#define MDBX_CXX11_CONSTEXPR inline
453#define MDBX_CXX11_CONSTEXPR_VAR const
454#else
455#define MDBX_CXX11_CONSTEXPR constexpr
456#define MDBX_CXX11_CONSTEXPR_VAR constexpr
457#endif /* MDBX_CXX11_CONSTEXPR */
458
461#if defined(DOXYGEN)
462#define MDBX_CXX14_CONSTEXPR constexpr
463#define MDBX_CXX14_CONSTEXPR_VAR constexpr
464#elif !defined(__cplusplus)
465#define MDBX_CXX14_CONSTEXPR __inline
466#define MDBX_CXX14_CONSTEXPR_VAR const
467#elif defined(DOXYGEN) || \
468 defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
469 ((defined(_MSC_VER) && _MSC_VER >= 1910) || (defined(__clang__) && __clang_major__ > 4) || \
470 (defined(__GNUC__) && __GNUC__ > 6) || (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
471#define MDBX_CXX14_CONSTEXPR constexpr
472#define MDBX_CXX14_CONSTEXPR_VAR constexpr
473#else
474#define MDBX_CXX14_CONSTEXPR inline
475#define MDBX_CXX14_CONSTEXPR_VAR const
476#endif /* MDBX_CXX14_CONSTEXPR */
477
478#if defined(__noreturn)
479#define MDBX_NORETURN __noreturn
480#elif defined(_Noreturn)
481#define MDBX_NORETURN _Noreturn
482#elif defined(DOXYGEN) || (defined(__cplusplus) && __cplusplus >= 201103L) || \
483 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
484#define MDBX_NORETURN [[noreturn]]
485#elif defined(__GNUC__) || __has_attribute(__noreturn__)
486#define MDBX_NORETURN __attribute__((__noreturn__))
487#elif defined(_MSC_VER) && !defined(__clang__)
488#define MDBX_NORETURN __declspec(noreturn)
489#else
490#define MDBX_NORETURN
491#endif /* MDBX_NORETURN */
492
493#ifndef MDBX_PRINTF_ARGS
494#if defined(__GNUC__) || __has_attribute(__format__) || defined(DOXYGEN)
495#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
496#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
497#else
498#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__printf__, format_index, first_arg)))
499#endif /* MinGW */
500#else
501#define MDBX_PRINTF_ARGS(format_index, first_arg)
502#endif
503#endif /* MDBX_PRINTF_ARGS */
504
505#if defined(DOXYGEN) || \
506 (defined(__cplusplus) && __cplusplus >= 201603L && __has_cpp_attribute(maybe_unused) && \
507 __has_cpp_attribute(maybe_unused) >= 201603L && (!defined(__clang__) || __clang__ > 19)) || \
508 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
509#define MDBX_MAYBE_UNUSED [[maybe_unused]]
510#elif defined(__GNUC__) || __has_attribute(__unused__)
511#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
512#else
513#define MDBX_MAYBE_UNUSED
514#endif /* MDBX_MAYBE_UNUSED */
515
516#if __has_attribute(no_sanitize) || defined(DOXYGEN)
517#define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
518#else
519#define MDBX_NOSANITIZE_ENUM
520#endif /* MDBX_NOSANITIZE_ENUM */
521
522/* Oh, below are some songs and dances since:
523 * - C++ requires explicit definition of the necessary operators.
524 * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
525 * the constexpr feature which is broken in most old compilers;
526 * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
527#if !defined(DEFINE_ENUM_FLAG_OPERATORS) && !defined(DOXYGEN)
528
529#ifdef __cplusplus
530#if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || (defined(__LCC__) && __LCC__ < 124) || \
531 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
532 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4)
533/* The constexpr feature is not available or (may be) broken */
534#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
535#else
536/* C always allows these operators for enums */
537#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
538#endif /* __cpp_constexpr */
539
542#define DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
543 extern "C++" { \
544 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { return ENUM(unsigned(a) | unsigned(b)); } \
545 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, ENUM b) { return a = a | b; } \
546 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { return ENUM(unsigned(a) & unsigned(b)); } \
547 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, unsigned b) { return ENUM(unsigned(a) & b); } \
548 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, ENUM b) { return ENUM(a & unsigned(b)); } \
549 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, ENUM b) { return a = a & b; } \
550 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, unsigned b) { return a = a & b; } \
551 MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
552 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { return ENUM(unsigned(a) ^ unsigned(b)); } \
553 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, ENUM b) { return a = a ^ b; } \
554 }
555#else /* __cplusplus */
556/* nope for C since it always allows these operators for enums */
557#define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
558#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
559#endif /* !__cplusplus */
560
561#elif !defined(CONSTEXPR_ENUM_FLAGS_OPERATIONS)
562
563#ifdef __cplusplus
564/* DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
565#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
566#else
567/* C always allows these operators for enums */
568#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
569#endif
570
571#endif /* DEFINE_ENUM_FLAG_OPERATORS */
572
574
575/*----------------------------------------------------------------------------*/
576
579
580#ifdef __cplusplus
581extern "C" {
582#endif
583
584/* MDBX version 0.14.x, but it is unstable/under-development yet. */
585#define MDBX_VERSION_UNSTABLE
586#define MDBX_VERSION_MAJOR 0
587#define MDBX_VERSION_MINOR 14
588
589#ifndef LIBMDBX_API
590#if defined(LIBMDBX_EXPORTS) || defined(DOXYGEN)
591#define LIBMDBX_API __dll_export
592#elif defined(LIBMDBX_IMPORTS)
593#define LIBMDBX_API __dll_import
594#else
595#define LIBMDBX_API
596#endif
597#endif /* LIBMDBX_API */
598
599#ifdef __cplusplus
600#if defined(__clang__) || __has_attribute(type_visibility) || defined(DOXYGEN)
601#define LIBMDBX_API_TYPE LIBMDBX_API __attribute__((type_visibility("default")))
602#else
603#define LIBMDBX_API_TYPE LIBMDBX_API
604#endif
605#else
606#define LIBMDBX_API_TYPE
607#endif /* LIBMDBX_API_TYPE */
608
609#if defined(LIBMDBX_IMPORTS)
610#define LIBMDBX_VERINFO_API __dll_import
611#else
612#define LIBMDBX_VERINFO_API __dll_export
613#endif /* LIBMDBX_VERINFO_API */
614
617 uint16_t major;
618 uint16_t minor;
619 uint16_t patch;
620 uint16_t tweak;
621 const char *semver_prerelease;
622 struct {
623 const char *datetime;
624 const char *tree;
625 const char *commit;
626 const char *describe;
627 } git;
628 const char *sourcery;
630
635 const char *datetime;
636 const char *target;
637 const char *options;
638 const char *compiler;
639 const char *flags;
640 const char *metadata;
644
645#if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
646/* MDBX internally uses global and thread local storage destructors to
647 * automatically (de)initialization, releasing reader lock table slots
648 * and so on.
649 *
650 * If MDBX built as a DLL this is done out-of-the-box by DllEntry() function,
651 * which called automatically by Windows core with passing corresponding reason
652 * argument.
653 *
654 * Otherwise, if MDBX was built not as a DLL, some black magic
655 * may be required depending of Windows version:
656 *
657 * - Modern Windows versions, including Windows Vista and later, provides
658 * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
659 * or dll file). In this case, MDBX capable of doing all automatically,
660 * therefore you DON'T NEED to call mdbx_module_handler()
661 * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
662 *
663 * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
664 * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
665 * of your DLL or application,
666 * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
667 *
668 * Therefore, building MDBX as a DLL is recommended for all version of Windows.
669 * So, if you doubt, just build MDBX as the separate DLL and don't care about
670 * the MDBX_MANUAL_MODULE_HANDLER. */
671
672#ifndef _WIN32_WINNT
673#error Non-dll build libmdbx requires target Windows version \
674 to be explicitly defined via _WIN32_WINNT for properly \
675 handling thread local storage destructors.
676#endif /* _WIN32_WINNT */
677
678#if _WIN32_WINNT >= 0x0600 /* Windows Vista */
679/* As described above mdbx_module_handler() is NOT needed for Windows Vista
680 * and later. */
681#define MDBX_MANUAL_MODULE_HANDLER 0
682#else
683/* As described above mdbx_module_handler() IS REQUIRED for Windows versions
684 * prior to Windows Vista. */
685#define MDBX_MANUAL_MODULE_HANDLER 1
686void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason, PVOID reserved);
687#endif
688
689#endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
690
691/* OPACITY STRUCTURES *********************************************************/
692
697#ifndef __cplusplus
698typedef struct MDBX_env MDBX_env;
699#else
700struct MDBX_env;
701#endif
702
708#ifndef __cplusplus
709typedef struct MDBX_txn MDBX_txn;
710#else
711struct MDBX_txn;
712#endif
713
721typedef uint32_t MDBX_dbi;
722
727#ifndef __cplusplus
729#else
730struct MDBX_cursor;
731#endif
732
747#ifndef HAVE_STRUCT_IOVEC
748struct iovec {
749 void *iov_base;
750 size_t iov_len;
751};
752#define HAVE_STRUCT_IOVEC
753#endif /* HAVE_STRUCT_IOVEC */
754
755#if defined(__sun) || defined(__SVR4) || defined(__svr4__)
756/* The `iov_len` is signed on Sun/Solaris.
757 * So define custom MDBX_val to avoid a lot of warnings. */
758struct MDBX_val {
759 void *iov_base;
760 size_t iov_len;
761};
762#ifndef __cplusplus
763typedef struct MDBX_val MDBX_val;
764#endif
765#else /* SunOS */
766typedef struct iovec MDBX_val;
767#endif /* ! SunOS */
768
771 MDBX_MAX_DBI = UINT32_C(32765),
772
774 MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
775
778
781};
782
783/* THE FILES *******************************************************************
784 * At the file system level, the environment corresponds to a pair of files. */
785
786#ifndef MDBX_LOCKNAME
789#if !(defined(_WIN32) || defined(_WIN64))
790#define MDBX_LOCKNAME "/mdbx.lck"
791#else
792#define MDBX_LOCKNAME_W L"\\mdbx.lck"
793#define MDBX_LOCKNAME_A "\\mdbx.lck"
794#ifdef UNICODE
795#define MDBX_LOCKNAME MDBX_LOCKNAME_W
796#else
797#define MDBX_LOCKNAME MDBX_LOCKNAME_A
798#endif /* UNICODE */
799#endif /* Windows */
800#endif /* MDBX_LOCKNAME */
801#ifndef MDBX_DATANAME
804#if !(defined(_WIN32) || defined(_WIN64))
805#define MDBX_DATANAME "/mdbx.dat"
806#else
807#define MDBX_DATANAME_W L"\\mdbx.dat"
808#define MDBX_DATANAME_A "\\mdbx.dat"
809#ifdef UNICODE
810#define MDBX_DATANAME MDBX_DATANAME_W
811#else
812#define MDBX_DATANAME MDBX_DATANAME_A
813#endif /* UNICODE */
814#endif /* Windows */
815#endif /* MDBX_DATANAME */
816
817#ifndef MDBX_LOCK_SUFFIX
819#if !(defined(_WIN32) || defined(_WIN64))
820#define MDBX_LOCK_SUFFIX "-lck"
821#else
822#define MDBX_LOCK_SUFFIX_W L"-lck"
823#define MDBX_LOCK_SUFFIX_A "-lck"
824#ifdef UNICODE
825#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_W
826#else
827#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_A
828#endif /* UNICODE */
829#endif /* Windows */
830#endif /* MDBX_LOCK_SUFFIX */
831
832/* DEBUG & LOGGING ************************************************************/
833
837
841typedef enum MDBX_log_level {
846
852
858
864
869
874
879
884
885#ifdef ENABLE_UBSAN
886 MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
887#endif /* ENABLE_UBSAN */
888
892
898typedef enum MDBX_debug_flags {
900
905
909
913
917
920
923
928
929#ifdef ENABLE_UBSAN
930 MDBX_DBG_MAX = ((unsigned)MDBX_LOG_MAX) << 16 | 127 /* avoid UBSAN false-positive trap by a tests */,
931#endif /* ENABLE_UBSAN */
932
936DEFINE_ENUM_FLAG_OPERATORS(MDBX_debug_flags)
937
938
952typedef void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt,
953 va_list args) MDBX_CXX17_NOEXCEPT;
954
956#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
957#define MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt *)(intptr_t)-1)
958
963
964typedef void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg,
965 unsigned length) MDBX_CXX17_NOEXCEPT;
966
968 MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size);
969
980typedef void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function,
981 unsigned line) MDBX_CXX17_NOEXCEPT;
982
993
1003LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize);
1004
1006MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
1007
1010MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line);
1012
1017typedef enum MDBX_env_flags {
1019
1025 MDBX_VALIDATION = UINT32_C(0x00002000),
1026
1043 MDBX_NOSUBDIR = UINT32_C(0x4000),
1044
1061 MDBX_RDONLY = UINT32_C(0x20000),
1062
1091 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1092
1106 MDBX_ACCEDE = UINT32_C(0x40000000),
1107
1137 MDBX_WRITEMAP = UINT32_C(0x80000),
1138
1208 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1209
1211 MDBX_NOTLS MDBX_DEPRECATED_ENUM = MDBX_NOSTICKYTHREADS,
1212
1232 MDBX_NORDAHEAD = UINT32_C(0x800000),
1233
1255 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1256
1268 MDBX_COALESCE MDBX_DEPRECATED_ENUM = UINT32_C(0x2000000),
1269
1292 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1293
1295 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1296
1297 /* SYNC MODES****************************************************************/
1339
1350
1367 MDBX_NOMETASYNC = UINT32_C(0x40000),
1368
1418 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1419
1426
1469
1472DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1473
1474
1478typedef enum MDBX_txn_flags {
1484
1490
1497#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1499#else
1500 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1501#endif
1502
1504 MDBX_TXN_TRY = UINT32_C(0x10000000),
1505
1509
1513
1514 /* Transaction state flags ---------------------------------------------- */
1515
1519 MDBX_TXN_INVALID = INT32_MIN,
1520
1525
1530
1535
1540
1545
1550
1557
1564
1570DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1571
1572
1576typedef enum MDBX_db_flags {
1579
1581 MDBX_REVERSEKEY = UINT32_C(0x02),
1582
1584 MDBX_DUPSORT = UINT32_C(0x04),
1585
1591 MDBX_INTEGERKEY = UINT32_C(0x08),
1592
1595 MDBX_DUPFIXED = UINT32_C(0x10),
1596
1600 MDBX_INTEGERDUP = UINT32_C(0x20),
1601
1603 MDBX_REVERSEDUP = UINT32_C(0x40),
1604
1606 MDBX_CREATE = UINT32_C(0x40000),
1607
1620DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1621
1622
1626typedef enum MDBX_put_flags {
1629
1631 MDBX_NOOVERWRITE = UINT32_C(0x10),
1632
1635 MDBX_NODUPDATA = UINT32_C(0x20),
1636
1641 MDBX_CURRENT = UINT32_C(0x40),
1642
1646 MDBX_ALLDUPS = UINT32_C(0x80),
1647
1650 MDBX_RESERVE = UINT32_C(0x10000),
1651
1654 MDBX_APPEND = UINT32_C(0x20000),
1655
1659 MDBX_APPENDDUP = UINT32_C(0x40000),
1660
1663 MDBX_MULTIPLE = UINT32_C(0x80000)
1665DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1666
1667
1701DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1702
1703
1828
1834typedef enum MDBX_error {
1837
1840
1843
1846
1849
1852
1855
1858
1861 MDBX_PANIC = -30795,
1862
1865
1868
1871
1874
1877
1880
1884
1887
1896
1906
1910
1915
1919
1923
1926
1929
1932 MDBX_BUSY = -30778,
1933
1936
1939
1944
1948
1951
1955
1959
1962
1968
1971
1975
1978 MDBX_OUSTED = -30411,
1979
1982
1983 /* The last of MDBX-added error codes */
1985
1986#if defined(_WIN32) || defined(_WIN64)
1987 MDBX_ENODATA = ERROR_HANDLE_EOF,
1988 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
1989 MDBX_EACCESS = ERROR_ACCESS_DENIED,
1990 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
1991 MDBX_EROFS = ERROR_FILE_READ_ONLY,
1992 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
1993 MDBX_EIO = ERROR_WRITE_FAULT,
1994 MDBX_EPERM = ERROR_INVALID_FUNCTION,
1995 MDBX_EINTR = ERROR_CANCELLED,
1996 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
1997 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
1998 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
1999#else /* Windows */
2000#if defined(ENODATA) || defined(DOXYGEN)
2001 MDBX_ENODATA = ENODATA,
2002#else
2003 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2004#endif /* ENODATA */
2005 MDBX_EINVAL = EINVAL,
2007 MDBX_ENOMEM = ENOMEM,
2008 MDBX_EROFS = EROFS,
2009#if defined(ENOTSUP) || defined(DOXYGEN)
2010 MDBX_ENOSYS = ENOTSUP,
2011#else
2012 MDBX_ENOSYS = ENOSYS,
2013#endif /* ENOTSUP */
2015 MDBX_EPERM = EPERM,
2016 MDBX_EINTR = EINTR,
2018#if defined(EREMOTEIO) || defined(DOXYGEN)
2020 MDBX_EREMOTE = EREMOTEIO,
2021#else
2022 MDBX_EREMOTE = ENOTBLK,
2023#endif /* EREMOTEIO */
2025#endif /* !Windows */
2026} MDBX_error_t;
2027
2032MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated(void) { return MDBX_UNABLE_EXTEND_MAPSIZE; }
2033#define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
2034
2053LIBMDBX_API const char *mdbx_strerror(int errnum);
2054
2079LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2081
2082#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2087LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2088
2093LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen);
2094#endif /* Bit of Windows' madness */
2095
2111
2416
2427LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value);
2428
2439LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue);
2440
2513LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2514
2515#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2519LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2520#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_openW(env, pathname, flags, mode)
2521#else
2522#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_open(env, pathname, flags, mode)
2523#endif /* Windows */
2524
2543
2564
2565#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2570LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode);
2571#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteW(pathname, mode)
2572#else
2573#define mdbx_env_deleteT(pathname, mode) mdbx_env_delete(pathname, mode)
2574#endif /* Windows */
2575
2629LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags);
2630
2685
2686#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2691LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags);
2692#define mdbx_env_copyT(env, dest, flags) mdbx_env_copyW(env, dest, flags)
2693
2699#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathnameW(txn, dest, path)
2700#else
2701#define mdbx_env_copyT(env, dest, flags) mdbx_env_copy(env, dest, flags)
2702#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathname(txn, dest, path)
2703#endif /* Windows */
2704
2730
2755
2760 uint32_t ms_psize;
2762 uint32_t ms_depth;
2764 uint64_t ms_leaf_pages;
2766 uint64_t ms_entries;
2767 uint64_t ms_mod_txnid;
2768};
2769#ifndef __cplusplus
2771typedef struct MDBX_stat MDBX_stat;
2772#endif
2773
2793LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes);
2794
2798MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes) {
2799 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2800}
2801
2806 struct {
2807 uint64_t lower;
2808 uint64_t upper;
2809 uint64_t current;
2810 uint64_t shrink;
2811 uint64_t grow;
2813 uint64_t mi_mapsize;
2814 uint64_t mi_last_pgno;
2820 uint32_t mi_maxreaders;
2821 uint32_t mi_numreaders;
2824
2833 struct {
2834 struct {
2835 uint64_t x, y;
2836 } current, meta[3];
2838
2855 uint32_t mi_mode;
2856
2862 struct {
2863 uint64_t newly;
2864 uint64_t cow;
2865 uint64_t clone;
2867 uint64_t split;
2868 uint64_t merge;
2869 uint64_t spill;
2870 uint64_t unspill;
2871 uint64_t wops;
2873 uint64_t prefault;
2874 uint64_t mincore;
2875 uint64_t msync;
2876 uint64_t fsync;
2878
2879 /* GUID of the database DXB file. */
2880 struct {
2881 uint64_t x, y;
2883};
2884#ifndef __cplusplus
2886typedef struct MDBX_envinfo MDBX_envinfo;
2887#endif
2888
2909LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes);
2913MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes) {
2914 return mdbx_env_info_ex(env, NULL, info, bytes);
2915}
2916
2953LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2954
2958inline int mdbx_env_sync(MDBX_env * env) { return mdbx_env_sync_ex(env, true, false); }
2959
2963inline int mdbx_env_sync_poll(MDBX_env * env) { return mdbx_env_sync_ex(env, false, true); }
2964
2988inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
2989 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
2990}
2991
3006inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
3007 int rc = MDBX_EINVAL;
3008 if (threshold) {
3009 uint64_t proxy = 0;
3010 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3011#ifdef assert
3012 assert(proxy <= SIZE_MAX);
3013#endif /* assert */
3014 *threshold = (size_t)proxy;
3015 }
3016 return rc;
3017}
3018
3049inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3050 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3051}
3052
3069inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3070 int rc = MDBX_EINVAL;
3071 if (period_seconds_16dot16) {
3072 uint64_t proxy = 0;
3073 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3074#ifdef assert
3075 assert(proxy <= UINT32_MAX);
3076#endif /* assert */
3077 *period_seconds_16dot16 = (unsigned)proxy;
3078 }
3079 return rc;
3080}
3081
3121LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3122
3126inline int mdbx_env_close(MDBX_env * env) { return mdbx_env_close_ex(env, false); }
3127
3128#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3206#endif /* Windows */
3207
3256DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3257
3258
3290 unsigned timeout_seconds_16dot16);
3291
3313
3324LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3325
3339LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3340
3341#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3346LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3347#define mdbx_env_get_pathT(env, dest) mdbx_env_get_pathW(env, dest)
3348#else
3349#define mdbx_env_get_pathT(env, dest) mdbx_env_get_path(env, dest)
3350#endif /* Windows */
3351
3365
3562LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper,
3563 intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize);
3564
3567MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3568 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3569}
3570
3586LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy);
3587
3591
3595
3600
3605
3611
3616
3622
3627
3633 MDBX_db_flags_t flags);
3634
3641
3646
3670inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3671 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3672}
3673
3685inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3686 int rc = MDBX_EINVAL;
3687 if (readers) {
3688 uint64_t proxy = 0;
3689 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3690 *readers = (unsigned)proxy;
3691 }
3692 return rc;
3693}
3694
3716inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3717 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3718}
3719
3730inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3731 int rc = MDBX_EINVAL;
3732 if (dbs) {
3733 uint64_t proxy = 0;
3734 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3735 *dbs = (MDBX_dbi)proxy;
3736 }
3737 return rc;
3738}
3739
3745
3760LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages);
3761
3772
3783
3788
3800
3812
3823
3833
3894 void *context);
3895
3950inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) {
3951 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3952}
3953
3965
3977
3984 uint64_t txn_id;
3985
3991
3995
3998
4002
4010
4017
4024};
4025#ifndef __cplusplus
4027typedef struct MDBX_txn_info MDBX_txn_info;
4028#endif
4029
4043LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt);
4044
4050
4061
4074
4082 uint32_t preparation;
4086 uint32_t audit;
4089 uint32_t write;
4092 uint32_t sync;
4094 uint32_t ending;
4096 uint32_t whole;
4098 uint32_t gc_cputime;
4099
4107 struct {
4110 uint32_t wloops;
4112 uint32_t coalescences;
4115 uint32_t wipes;
4119 uint32_t flushes;
4123 uint32_t kicks;
4124
4127 uint32_t work_counter;
4130 uint32_t work_rtime_monotonic;
4134 uint32_t work_xtime_cpu;
4137 uint32_t work_rsteps;
4140 uint32_t work_xpages;
4143 uint32_t work_majflt;
4144
4147 uint32_t self_counter;
4150 uint32_t self_rtime_monotonic;
4154 uint32_t self_xtime_cpu;
4157 uint32_t self_rsteps;
4160 uint32_t self_xpages;
4163 uint32_t self_majflt;
4164 /* Для разборок с pnl_merge() */
4165 struct {
4166 uint32_t time;
4167 uint64_t volume;
4168 uint32_t calls;
4169 } pnl_merge_work, pnl_merge_self;
4171};
4172#ifndef __cplusplus
4175#endif
4176
4183
4225inline int mdbx_txn_commit(MDBX_txn * txn) { return mdbx_txn_commit_ex(txn, NULL); }
4226
4261
4274
4309
4353LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4354
4396LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4397
4419
4431 uint64_t x, y, z, v;
4432};
4433#ifndef __cplusplus
4435typedef struct MDBX_canary MDBX_canary;
4436#endif
4437
4457
4469
4490typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4491
4581LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi);
4585
4602MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi,
4603 MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4606MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4607 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4608
4624LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4628
4648typedef int(MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4649 const struct MDBX_stat *stat, MDBX_dbi dbi) MDBX_CXX17_NOEXCEPT;
4650
4672
4685
4687
4688MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
4689
4691
4692MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
4693
4694MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
4695 return UINT64_C(0x8000000000000000) + i64;
4696}
4697
4698MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
4699 return UINT32_C(0x80000000) + i32;
4700}
4701
4702
4709
4711
4713
4715
4718
4733LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes);
4734
4750LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask);
4751
4755typedef enum MDBX_dbi_state {
4765DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
4766
4767
4778LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state);
4783inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
4784 unsigned state;
4785 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
4786}
4787
4814
4826LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
4827
4862LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data);
4863
4894LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count);
4895
4925
5007LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags);
5008
5052LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data,
5053 MDBX_put_flags_t flags);
5054
5055typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes);
5056LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data,
5057 MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver,
5058 void *preserver_context);
5059
5085LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data);
5086
5110
5121
5132
5163
5190
5204
5236
5257
5280
5303LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count);
5304
5325inline int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind) {
5326 return mdbx_txn_release_all_cursors_ex(txn, unbind, NULL);
5327}
5328
5354
5360
5366
5378
5400LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival);
5401
5434
5449
5479typedef int(MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) MDBX_CXX17_NOEXCEPT;
5480
5549LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context,
5550 MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg);
5551
5637 MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value,
5638 MDBX_cursor_op turn_op, void *arg);
5639
5681LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit,
5682 MDBX_cursor_op op);
5683
5765
5797
5815LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count);
5816
5839LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes);
5840
5854
5867
5880
5893
5906
5931
5951LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items);
5952
5974 ptrdiff_t *distance_items);
5975
6000LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key,
6001 const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data,
6002 ptrdiff_t *distance_items);
6003
6006#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
6007
6042
6064LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment);
6065
6082 const MDBX_val *b);
6083
6087
6104 const MDBX_val *b);
6105
6109
6135typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid,
6136 uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6137
6150
6160
6173MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent);
6174
6194
6209
6283typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6284 unsigned gap, size_t space, int retry) MDBX_CXX17_NOEXCEPT;
6285
6305
6319
6325
6329LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
6330
6335
6345LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable);
6346
6347#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6352LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta,
6353 bool writeable);
6354#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6355 mdbx_env_open_for_recoveryW(env, pathname, target_mets, writeable)
6356#else
6357#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6358 mdbx_env_open_for_recovery(env, pathname, target_mets, writeable)
6359#endif /* Windows */
6360
6366LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
6367
6399LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes);
6400#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6405LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes);
6406#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfoW(pathname, info, bytes)
6407#else
6408#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfo(pathname, info, bytes)
6409#endif /* Windows */
6410
6434DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
6435
6436
6454
6472
6475typedef struct MDBX_chk_line {
6476 struct MDBX_chk_context *ctx;
6478 char *begin, *end, *out;
6480
6483typedef struct MDBX_chk_issue {
6484 struct MDBX_chk_issue *next;
6485 size_t count;
6486 const char *caption;
6488
6491typedef struct MDBX_chk_scope {
6493 struct MDBX_chk_internal *internal;
6494 const void *object;
6498 union {
6499 void *ptr;
6500 size_t number;
6501 } usr_z, usr_v, usr_o;
6503
6507typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
6508
6514 struct {
6515 size_t begin, end, amount, count;
6517};
6518
6522typedef struct MDBX_chk_table {
6524
6526#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
6528#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
6530#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
6531
6534 int id;
6535
6537 struct {
6538 size_t all, empty, other;
6539 size_t branch, leaf;
6541 } pages;
6561
6583
6599typedef struct MDBX_chk_callbacks {
6601 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt,
6602 va_list args);
6605 void (*issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue,
6606 const char *extra_fmt, va_list extra_args);
6608 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err);
6610
6611 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number,
6612 const MDBX_val *key, const MDBX_val *value);
6613
6616
6620 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
6621 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
6622 void (*print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix);
6624
6655 const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity,
6656 unsigned timeout_seconds_16dot16);
6657
6664
6666
6668
6669#ifdef __cplusplus
6670} /* extern "C" */
6671#endif
6672
6673#endif /* LIBMDBX_H */
#define MDBX_NOTHROW_CONST_FUNCTION
The 'const nothrow' function attribute for optimization.
Definition mdbx.h:300
#define MDBX_CXX17_NOEXCEPT
Definition mdbx.h:414
#define MDBX_NOTHROW_PURE_FUNCTION
The 'pure nothrow' function attribute for optimization.
Definition mdbx.h:259
#define MDBX_NORETURN
Definition mdbx.h:484
uint64_t mi_mapsize
Definition mdbx.h:2813
uint32_t wipes
Количество уничтожений предыдущих надежных/устойчивых точек фиксации при работе в режиме MDBX_UTTERLY...
uint64_t txn_space_dirty
Definition mdbx.h:4023
struct MDBX_envinfo::@012005163333303136244023145022271211024347140371 mi_geo
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4098
const char * describe
uint32_t mi_dxb_pagesize
Definition mdbx.h:2822
uint32_t mi_maxreaders
Definition mdbx.h:2820
uint64_t v
Definition mdbx.h:4431
uint32_t coalescences
Количество итераций слияния записей GC.
uint32_t mi_numreaders
Definition mdbx.h:2821
uint16_t patch
Definition mdbx.h:619
const char * metadata
Definition mdbx.h:640
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2846
uint32_t self_xpages
Количество запросов на выделение последовательностей страниц для самой GC.
uint16_t major
Definition mdbx.h:617
uint64_t txn_reader_lag
Definition mdbx.h:3990
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2819
uint64_t txn_space_leftover
Definition mdbx.h:4016
struct MDBX_envinfo::@366225332126364017271247035205240304242123014254 mi_pgop_stat
uint64_t txn_space_used
Definition mdbx.h:3994
const char * datetime
Definition mdbx.h:635
uint64_t mi_recent_txnid
Definition mdbx.h:2815
uint64_t mi_autosync_threshold
Definition mdbx.h:2842
const char * semver_prerelease
Definition mdbx.h:621
uint32_t wloops
Количество итераций обновления GC, больше 1 если были повторы/перезапуски.
uint64_t ms_branch_pages
Definition mdbx.h:2763
uint64_t ms_entries
Definition mdbx.h:2766
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4084
uint16_t minor
Definition mdbx.h:618
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2852
uint64_t y
Definition mdbx.h:4431
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:4092
uint64_t txn_space_limit_soft
Definition mdbx.h:3997
uint32_t mi_mode
Definition mdbx.h:2855
const char * options
Definition mdbx.h:637
uint64_t txn_id
Definition mdbx.h:3984
const char * sourcery
Definition mdbx.h:628
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2816
uint64_t ms_overflow_pages
Definition mdbx.h:2765
uint32_t self_rsteps
Количество итераций поиска внутри GC при выделении страниц для целей поддержки и обновления самой GC.
struct MDBX_envinfo::@036110245144360117333346206230046231375034327042 mi_bootid
A mostly unique ID that is regenerated on each boot.
uint32_t self_majflt
Количество страничных промахов (page faults) внутри GC при выделении и подготовки страниц для самой G...
uint32_t work_majflt
Количество страничных промахов (page faults) внутри GC при выделении и подготовки страниц для данных ...
uint32_t preparation
Duration of preparation (commit child transactions, update table's records and cursors destroying).
Definition mdbx.h:4082
uint64_t z
Definition mdbx.h:4431
uint64_t txn_space_limit_hard
Definition mdbx.h:4001
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4096
uint32_t flushes
Количество принудительных фиксаций на диск во избежания приращения БД при работе вне режима MDBX_UTTE...
uint32_t work_xpages
Количество запросов на выделение последовательностей страниц ради данных пользователя.
const char * flags
Definition mdbx.h:639
uint32_t self_counter
Счетчик выполнения по медленному пути (slow path execution count) GC для целей поддержки и обновления...
uint32_t self_rtime_monotonic
Время "по настенным часам" затраченное на чтение и поиск внутри GC для целей поддержки и обновления с...
struct MDBX_commit_latency::@063112077126007214166021162020057361221355030117 gc_prof
Информация для профилирования работы GC.
uint64_t mi_meta_sign[3]
Definition mdbx.h:2819
uint32_t ms_psize
Definition mdbx.h:2760
uint32_t kicks
Количество обращений к механизму Handle-Slow-Readers во избежания приращения БД.
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4086
uint16_t tweak
Definition mdbx.h:620
const char * target
Definition mdbx.h:636
uint32_t write
Duration of writing dirty/modified data pages to a filesystem, i.e. the summary duration of a write()...
Definition mdbx.h:4089
uint64_t txn_space_retired
Definition mdbx.h:4009
uint32_t ms_depth
Definition mdbx.h:2762
uint64_t mi_last_pgno
Definition mdbx.h:2814
uint32_t work_counter
Счетчик выполнения по медленному пути (slow path execution count) GC ради данных пользователя.
uint32_t self_xtime_cpu
Время ЦПУ в режиме пользователе затраченное на подготовку страниц извлекаемых из GC для целей поддерж...
uint32_t ending
Duration of transaction ending (releasing resources).
Definition mdbx.h:4094
uint64_t ms_mod_txnid
Definition mdbx.h:2767
uint32_t work_rsteps
Количество итераций поиска внутри GC при выделении страниц ради данных пользователя.
const char * datetime
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2817
uint64_t ms_leaf_pages
Definition mdbx.h:2764
uint64_t x
Definition mdbx.h:4431
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2849
uint64_t mi_unsync_volume
Definition mdbx.h:2840
uint32_t mi_sys_pagesize
Definition mdbx.h:2823
struct MDBX_version_info::@246336125106374236367351214106016351032060025144 git
uint32_t work_rtime_monotonic
Время "по настенным часам" затраченное на чтение и поиск внутри GC ради данных пользователя.
uint32_t work_xtime_cpu
Время ЦПУ в режиме пользователе затраченное на подготовку страниц извлекаемых из GC для данных пользо...
const char * compiler
Definition mdbx.h:638
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...
MDBX_constants
Definition mdbx.h:769
mode_t mdbx_mode_t
Definition mdbx.h:174
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition mdbx.h:5055
#define LIBMDBX_API
Definition mdbx.h:591
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the table. .
Definition mdbx.h:766
LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver, void *preserver_context)
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
pthread_t mdbx_tid_t
Definition mdbx.h:173
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:698
int mdbx_filehandle_t
Definition mdbx.h:171
LIBMDBX_API const char * mdbx_liberr2str(int errnum)
pid_t mdbx_pid_t
Definition mdbx.h:172
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:612
@ MDBX_MAX_PAGESIZE
Definition mdbx.h:780
@ MDBX_MAXDATASIZE
Definition mdbx.h:774
@ MDBX_MAX_DBI
Definition mdbx.h:771
@ MDBX_MIN_PAGESIZE
Definition mdbx.h:777
libmdbx build information
Definition mdbx.h:634
The fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h:4430
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4079
Information about the environment.
Definition mdbx.h:2805
Statistics for a table in the environment.
Definition mdbx.h:2759
Information about the transaction.
Definition mdbx.h:3981
libmdbx version information,
Definition mdbx.h:616
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
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_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_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg)
Сканирует таблицу с использованием передаваемого предиката, с уменьшением сопутствующих накладных рас...
LIBMDBX_API int mdbx_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:1626
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.
LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes)
Return count values (aka duplicates) and nested b-tree statistics for current key.
LIBMDBX_API int mdbx_cursor_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_cmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two keys according to a particular table.
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:4490
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)
Replace items 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.
int MDBX_predicate_func(void *context, MDBX_val *key, MDBX_val *value, void *arg) noexcept
Тип предикативных функций обратного вызова используемых mdbx_cursor_scan() и mdbx_cursor_scan_from() ...
Definition mdbx.h:5479
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_MULTIPLE
Definition mdbx.h:1663
@ MDBX_ALLDUPS
Definition mdbx.h:1646
@ MDBX_CURRENT
Definition mdbx.h:1641
@ MDBX_APPENDDUP
Definition mdbx.h:1659
@ MDBX_NODUPDATA
Definition mdbx.h:1635
@ MDBX_APPEND
Definition mdbx.h:1654
@ MDBX_UPSERT
Definition mdbx.h:1628
@ MDBX_RESERVE
Definition mdbx.h:1650
@ MDBX_NOOVERWRITE
Definition mdbx.h:1631
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу.
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:5325
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:1707
LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival)
Сравнивает позицию курсоров.
LIBMDBX_API int mdbx_cursor_on_last_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на последнем или единственном мульти-значении соответствующем ключу.
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)
Сбрасывает состояние курсора.
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:728
LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx)
Set application information associated with the cursor.
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_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:1784
@ MDBX_SEEK_AND_GET_MULTIPLE
Definition mdbx.h:1826
@ MDBX_GET_CURRENT
Definition mdbx.h:1722
@ MDBX_GET_BOTH
Definition mdbx.h:1715
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1803
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1719
@ MDBX_SET_KEY
Definition mdbx.h:1762
@ MDBX_FIRST_DUP
Definition mdbx.h:1712
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1802
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1727
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1813
@ MDBX_NEXT_NODUP
Definition mdbx.h:1747
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1810
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1811
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1818
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1770
@ MDBX_SET_RANGE
Definition mdbx.h:1765
@ MDBX_LAST_DUP
Definition mdbx.h:1733
@ MDBX_PREV
Definition mdbx.h:1750
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1820
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1821
@ MDBX_LAST
Definition mdbx.h:1730
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1801
@ MDBX_PREV_DUP
Definition mdbx.h:1753
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1809
@ MDBX_SET
Definition mdbx.h:1759
@ MDBX_NEXT
Definition mdbx.h:1736
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1804
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1817
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1744
@ MDBX_PREV_NODUP
Definition mdbx.h:1756
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1819
@ MDBX_NEXT_DUP
Definition mdbx.h:1739
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1812
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1798
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1805
@ MDBX_FIRST
Definition mdbx.h:1709
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_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)
Переименовает таблицу по DBI-дескриптору
LIBMDBX_API int mdbx_dbi_rename2(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name)
Переименовает таблицу по DBI-дескриптору
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:721
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1576
@ MDBX_INTEGERDUP
Definition mdbx.h:1600
@ MDBX_DB_ACCEDE
Definition mdbx.h:1618
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1578
@ MDBX_REVERSEKEY
Definition mdbx.h:1581
@ MDBX_DUPFIXED
Definition mdbx.h:1595
@ MDBX_INTEGERKEY
Definition mdbx.h:1591
@ MDBX_REVERSEDUP
Definition mdbx.h:1603
@ MDBX_CREATE
Definition mdbx.h:1606
@ MDBX_DUPSORT
Definition mdbx.h:1584
LIBMDBX_API const char * mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize)
Dump given MDBX_val to the buffer.
MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt,...) MDBX_PRINTF_ARGS(1
Panics with message and causes abnormal process termination.
void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg, unsigned length) noexcept
Definition mdbx.h:964
void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function, unsigned line) noexcept
A callback function for most MDBX assert() failures, called before printing the message and aborting.
Definition mdbx.h:980
MDBX_log_level_t
Definition mdbx.h:841
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:898
LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func)
Set or reset the assert() callback of the environment.
MDBX_NORETURN LIBMDBX_API void MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line)
Panics with asserton failed message and causes abnormal process termination.
void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt, va_list args) noexcept
A debug-logger callback function, called before printing the message and aborting.
Definition mdbx.h:952
LIBMDBX_API int mdbx_setup_debug(MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func *logger)
Setup global log-level, debug options and debug logger.
LIBMDBX_API int mdbx_setup_debug_nofmt(MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size)
@ MDBX_LOG_EXTRA
Definition mdbx.h:883
@ MDBX_LOG_WARN
Definition mdbx.h:857
@ MDBX_LOG_TRACE
Definition mdbx.h:878
@ MDBX_LOG_DEBUG
Definition mdbx.h:873
@ MDBX_LOG_FATAL
Definition mdbx.h:845
@ MDBX_LOG_ERROR
Definition mdbx.h:851
@ MDBX_LOG_NOTICE
Definition mdbx.h:863
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:890
@ MDBX_LOG_VERBOSE
Definition mdbx.h:868
@ MDBX_DBG_ASSERT
Definition mdbx.h:904
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:927
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:922
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:919
@ MDBX_DBG_NONE
Definition mdbx.h:899
@ MDBX_DBG_DUMP
Definition mdbx.h:916
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:934
@ MDBX_DBG_AUDIT
Definition mdbx.h:908
@ MDBX_DBG_JITTER
Definition mdbx.h:912
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(int errnum)
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:6283
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1834
LIBMDBX_API const char * mdbx_strerror_r(int errnum, char *buf, size_t buflen)
Return a string describing a given error code.
LIBMDBX_API const char * mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen)
@ MDBX_PANIC
Definition mdbx.h:1861
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1848
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1950
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1895
@ MDBX_EACCESS
Definition mdbx.h:2006
@ MDBX_EIO
Definition mdbx.h:2014
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1854
@ MDBX_TXN_FULL
Definition mdbx.h:1879
@ MDBX_DUPLICATED_CLK
Definition mdbx.h:1970
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1864
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1947
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1961
@ MDBX_EREMOTE
Definition mdbx.h:2020
@ MDBX_TOO_LARGE
Definition mdbx.h:1954
@ MDBX_EBADSIGN
Definition mdbx.h:1943
@ MDBX_CURSOR_FULL
Definition mdbx.h:1883
@ MDBX_ENOFILE
Definition mdbx.h:2017
@ MDBX_BAD_TXN
Definition mdbx.h:1914
@ MDBX_ENODATA
Definition mdbx.h:2001
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1928
@ MDBX_CORRUPTED
Definition mdbx.h:1857
@ MDBX_EPERM
Definition mdbx.h:2015
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1958
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1967
@ MDBX_SUCCESS
Definition mdbx.h:1836
@ MDBX_NOTFOUND
Definition mdbx.h:1851
@ MDBX_RESULT_TRUE
Definition mdbx.h:1842
@ MDBX_INVALID
Definition mdbx.h:1867
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1918
@ MDBX_BUSY
Definition mdbx.h:1932
@ MDBX_OUSTED
Definition mdbx.h:1978
@ MDBX_DBS_FULL
Definition mdbx.h:1873
@ MDBX_EINVAL
Definition mdbx.h:2005
@ MDBX_BAD_RSLOT
Definition mdbx.h:1909
@ MDBX_ENOMEM
Definition mdbx.h:2007
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1935
@ MDBX_RESULT_FALSE
Definition mdbx.h:1839
@ MDBX_EINTR
Definition mdbx.h:2016
@ MDBX_READERS_FULL
Definition mdbx.h:1876
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:1984
@ MDBX_BAD_DBI
Definition mdbx.h:1922
@ MDBX_KEYEXIST
Definition mdbx.h:1845
@ MDBX_DANGLING_DBI
Definition mdbx.h:1974
@ MDBX_EDEADLK
Definition mdbx.h:2024
@ MDBX_PAGE_FULL
Definition mdbx.h:1886
@ MDBX_MAP_FULL
Definition mdbx.h:1870
@ MDBX_PROBLEM
Definition mdbx.h:1925
@ MDBX_ENOSYS
Definition mdbx.h:2010
@ MDBX_EMULTIVAL
Definition mdbx.h:1938
@ MDBX_EROFS
Definition mdbx.h:2008
@ MDBX_MVCC_RETARDED
Definition mdbx.h:1981
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1905
LIBMDBX_API MDBX_cmp_func * mdbx_get_datacmp(MDBX_db_flags_t flags)
Returns default internal data's comparator for given table flags.
LIBMDBX_API int mdbx_reader_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:1670
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:2958
LIBMDBX_API MDBX_cmp_func * mdbx_get_keycmp(MDBX_db_flags_t flags)
Returns default internal key's comparator for given table flags.
LIBMDBX_API int mdbx_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.
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:2963
LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode)
Delete the environment's files in a proper and multiprocess-safe way.
LIBMDBX_API int mdbx_env_resurrect_after_fork(MDBX_env *env)
Восстанавливает экземпляр среды в дочернем процессе после ветвления родительского процесса посредство...
MDBX_env_delete_mode_t
Deletion modes for mdbx_env_delete().
Definition mdbx.h:2528
LIBMDBX_API int mdbx_env_copy2fd(MDBX_env *env, mdbx_filehandle_t fd, MDBX_copy_flags_t flags)
Copy an environment to the specified file descriptor, with options.
LIBMDBX_API int mdbx_cursor_ignord(MDBX_cursor *cursor)
Служебная функция для использования в утилитах.
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:1689
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1671
@ MDBX_CP_COMPACT
Definition mdbx.h:1675
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1694
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1685
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1678
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1681
@ MDBX_CP_OVERWRITE
Definition mdbx.h:1698
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2541
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2535
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2538
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:3126
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1017
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)
Получает базовую информацию о БД не открывая её.
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)
Получает базовую информацию о БД не открывая её.
@ MDBX_NORDAHEAD
Definition mdbx.h:1232
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1018
@ MDBX_COALESCE
Definition mdbx.h:1268
@ MDBX_NOMETASYNC
Definition mdbx.h:1367
@ MDBX_LIFORECLAIM
Definition mdbx.h:1292
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1418
@ MDBX_NOTLS
Definition mdbx.h:1211
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1349
@ MDBX_PAGEPERTURB
Definition mdbx.h:1295
@ MDBX_WRITEMAP
Definition mdbx.h:1137
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1208
@ MDBX_EXCLUSIVE
Definition mdbx.h:1091
@ MDBX_NOMEMINIT
Definition mdbx.h:1255
@ MDBX_MAPASYNC
Definition mdbx.h:1425
@ MDBX_ACCEDE
Definition mdbx.h:1106
@ MDBX_NOSUBDIR
Definition mdbx.h:1043
@ MDBX_RDONLY
Definition mdbx.h:1061
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1468
@ MDBX_VALIDATION
Definition mdbx.h:1025
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:3567
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3716
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:3049
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2115
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:2988
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3212
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:3670
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:2220
@ MDBX_opt_subpage_room_threshold
Задаёт в % минимальный объём свободного места на основной странице, при отсутствии которого вложенные...
Definition mdbx.h:2393
@ MDBX_opt_subpage_limit
Задаёт в % максимальный размер вложенных страниц, используемых для размещения небольшого количества м...
Definition mdbx.h:2387
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2216
@ MDBX_opt_prefer_waf_insteadof_balance
Управляет выбором между стремлением к равномерности наполнения страниц, либо уменьшением количества и...
Definition mdbx.h:2372
@ 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:2320
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2124
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2287
@ MDBX_opt_subpage_reserve_prereq
Задаёт в % минимальный объём свободного места на основной странице, при наличии которого,...
Definition mdbx.h:2409
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2147
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2252
@ 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:2275
@ 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:2187
@ 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:2174
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2141
@ MDBX_opt_subpage_reserve_limit
Задаёт в % ограничение резервирования места на вложенных страницах.
Definition mdbx.h:2414
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2236
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2153
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2201
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2315
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2347
@ MDBX_warmup_touchlimit
Definition mdbx.h:3251
@ MDBX_warmup_force
Definition mdbx.h:3221
@ MDBX_warmup_oomsafe
Definition mdbx.h:3228
@ MDBX_warmup_release
Definition mdbx.h:3254
@ MDBX_warmup_lock
Definition mdbx.h:3243
@ MDBX_warmup_default
Definition mdbx.h:3215
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:3685
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:3069
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:4783
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:2913
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:3006
LIBMDBX_API int mdbx_enumerate_tables(const MDBX_txn *txn, MDBX_table_enum_func *func, void *ctx)
Перечисляет пользовательские именнованные таблицы.
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:3594
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:4755
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:3590
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 void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
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:6135
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:3730
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.
LIBMDBX_API int mdbx_reader_list(const MDBX_env *env, MDBX_reader_list_func *func, void *ctx)
Enumerate the entries in the reader lock table.
LIBMDBX_API int mdbx_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:2798
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.
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
Функция обратного вызова для перечисления пользовательских именованных таблиц.
Definition mdbx.h:4648
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.
@ MDBX_DBI_DIRTY
Definition mdbx.h:4757
@ MDBX_DBI_FRESH
Definition mdbx.h:4761
@ MDBX_DBI_STALE
Definition mdbx.h:4759
@ MDBX_DBI_CREAT
Definition mdbx.h:4763
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_park(MDBX_txn *txn, bool autounpark)
Переводит читающую транзакцию в "припаркованное" состояние.
LIBMDBX_API int mdbx_txn_begin_ex(MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn, void *context)
Create a transaction with a user provided context pointer for use with the environment.
int mdbx_txn_commit(MDBX_txn *txn)
Commit all the operations of a transaction into the database.
Definition mdbx.h:4225
LIBMDBX_API int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency)
Commit all the operations of a transaction into the database and collect latency information.
LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted)
Распарковывает ранее припаркованную читающую транзакцию.
MDBX_txn_flags_t
Definition mdbx.h:1478
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_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:3950
LIBMDBX_API int mdbx_txn_abort(MDBX_txn *txn)
Abandon all the operations of the transaction instead of saving them.
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition mdbx.h:709
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:1489
@ MDBX_TXN_ERROR
Definition mdbx.h:1529
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1508
@ MDBX_TXN_SPILLS
Definition mdbx.h:1539
@ MDBX_TXN_OUSTED
Definition mdbx.h:1563
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1544
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1498
@ MDBX_TXN_INVALID
Definition mdbx.h:1519
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1568
@ MDBX_TXN_PARKED
Definition mdbx.h:1549
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1512
@ MDBX_TXN_DIRTY
Definition mdbx.h:1534
@ MDBX_TXN_READWRITE
Definition mdbx.h:1483
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1556
@ MDBX_TXN_TRY
Definition mdbx.h:1504
@ MDBX_TXN_FINISHED
Definition mdbx.h:1524
MDBX_chk_severity_t verbosity
Definition mdbx.h:6496
MDBX_txn * txn
Definition mdbx.h:6567
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:6605
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:6622
size_t pad
Definition mdbx.h:6513
void(* print_done)(MDBX_chk_line_t *)
Definition mdbx.h:6619
struct MDBX_chk_internal * internal
Definition mdbx.h:6565
struct MDBX_chk_histogram nested_tree
Histogram of nested trees height, span length for GC.
uint8_t scope_nesting
Definition mdbx.h:6569
char * end
Definition mdbx.h:6478
uint8_t scope_depth
Definition mdbx.h:6477
struct MDBX_chk_histogram key_len
Keys length histogram.
int(* stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t)
Definition mdbx.h:6614
size_t ones
Definition mdbx.h:6513
int(* stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err)
Definition mdbx.h:6615
int(* table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err)
Definition mdbx.h:6608
void(* print_format)(MDBX_chk_line_t *, const char *fmt, va_list args)
Definition mdbx.h:6621
struct MDBX_chk_internal * internal
Definition mdbx.h:6493
char * begin
Definition mdbx.h:6478
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:6601
size_t subtotal_issues
Definition mdbx.h:6497
struct MDBX_chk_histogram deep
Tree deep histogram.
uint8_t severity
Definition mdbx.h:6477
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:6523
void(* scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner)
Definition mdbx.h:6604
struct MDBX_chk_context * ctx
Definition mdbx.h:6476
MDBX_db_flags_t flags
Definition mdbx.h:6533
int(* scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, int err)
Definition mdbx.h:6603
void(* print_flush)(MDBX_chk_line_t *)
Definition mdbx.h:6618
struct MDBX_chk_issue * next
Definition mdbx.h:6484
struct MDBX_chk_histogram large_pages
Histogram of large/overflow pages length.
char * out
Definition mdbx.h:6478
struct MDBX_chk_histogram val_len
Values length histogram.
void(* print_chars)(MDBX_chk_line_t *, const char *str, size_t len)
Definition mdbx.h:6620
const MDBX_chk_table_t *const * tables
const void * object
Definition mdbx.h:6494
size_t count
Definition mdbx.h:6513
const char * caption
Definition mdbx.h:6486
MDBX_chk_stage_t stage
Definition mdbx.h:6495
struct MDBX_chk_histogram nested_tree_filling
Histogram of nested tree(s) branch and leaf pages filling in percents.
struct MDBX_chk_histogram multival
Number of multi-values (aka duplicates) histogram.
MDBX_env * env
Definition mdbx.h:6566
uint8_t empty
Definition mdbx.h:6477
size_t amount
Definition mdbx.h:6513
MDBX_chk_scope_t * scope
Definition mdbx.h:6568
MDBX_chk_issue_t * issues
Definition mdbx.h:6492
size_t payload_bytes
Definition mdbx.h:6536
size_t count
Definition mdbx.h:6485
MDBX_val name
Definition mdbx.h:6532
size_t lost_bytes
Definition mdbx.h:6536
bool(* check_break)(MDBX_chk_context_t *ctx)
Definition mdbx.h:6600
void(* table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table)
Definition mdbx.h:6609
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:6611
struct MDBX_chk_histogram tree_filling
Histogram of branch and leaf pages filling in percents.
int id
Definition mdbx.h:6534
LIBMDBX_API int mdbx_env_chk_encount_problem(MDBX_chk_context_t *ctx)
Вспомогательная функция для подсчета проблем детектируемых приложением, в том числе,...
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)
Проверяет целостность базы данных.
MDBX_chk_stage_t
Стадии проверки, сообщаемые через обратные вызовы при проверке целостности базы данных.
Definition mdbx.h:6458
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение...
Definition mdbx.h:6507
MDBX_chk_flags_t
Флаги/опции для проверки целостности базы данных.
Definition mdbx.h:6415
MDBX_chk_severity_t
Уровни логирование/детализации информации, поставляемой через обратные вызовы при проверке целостност...
Definition mdbx.h:6439
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_turn_for_recovery(MDBX_env *env, unsigned target_meta)
Turn database to the specified meta-page.
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.
@ MDBX_chk_gc
Definition mdbx.h:6464
@ MDBX_chk_init
Definition mdbx.h:6460
@ MDBX_chk_finalize
Definition mdbx.h:6470
@ MDBX_chk_space
Definition mdbx.h:6465
@ MDBX_chk_lock
Definition mdbx.h:6461
@ MDBX_chk_none
Definition mdbx.h:6459
@ MDBX_chk_maindb
Definition mdbx.h:6466
@ MDBX_chk_unlock
Definition mdbx.h:6469
@ MDBX_chk_meta
Definition mdbx.h:6462
@ MDBX_chk_conclude
Definition mdbx.h:6468
@ MDBX_chk_tree
Definition mdbx.h:6463
@ MDBX_chk_tables
Definition mdbx.h:6467
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:6424
@ MDBX_CHK_READWRITE
Definition mdbx.h:6421
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:6417
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:6427
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:6432
@ MDBX_chk_processing
Definition mdbx.h:6448
@ MDBX_chk_result
Definition mdbx.h:6446
@ MDBX_chk_details
Definition mdbx.h:6451
@ MDBX_chk_extra
Definition mdbx.h:6452
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:6440
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:6441
@ MDBX_chk_notice
Definition mdbx.h:6445
@ MDBX_chk_resolution
Definition mdbx.h:6447
@ MDBX_chk_warning
Definition mdbx.h:6444
@ MDBX_chk_fatal
Definition mdbx.h:6442
@ MDBX_chk_info
Definition mdbx.h:6449
@ MDBX_chk_error
Definition mdbx.h:6443
@ MDBX_chk_verbose
Definition mdbx.h:6450
Набор функций обратного вызова используемых при проверке целостности базы данных.
Definition mdbx.h:6599
Контекст проверки целостности базы данных.
Definition mdbx.h:6564
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД.
Definition mdbx.h:6512
Проблема обнаруженная при проверке целостности базы данных.
Definition mdbx.h:6483
Виртуальная строка отчета, формируемого при проверке целостности базы данных.
Definition mdbx.h:6475
Иерархический контекст при проверке целостности базы данных.
Definition mdbx.h:6491
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных.
Definition mdbx.h:6522
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:4694
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:4698
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)