libmdbx 0.14.1.177 (2025-12-04T00:18:57+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
843typedef enum MDBX_log_level {
848
854
860
866
871
876
881
886
887#ifdef ENABLE_UBSAN
888 MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
889#endif /* ENABLE_UBSAN */
890
894
902typedef enum MDBX_debug_flags {
904
909
913
917
921
924
927
931
932#ifdef ENABLE_UBSAN
933 MDBX_DBG_MAX = ((unsigned)MDBX_LOG_MAX) << 16 | 127 /* avoid UBSAN false-positive trap by a tests */,
934#endif /* ENABLE_UBSAN */
935
939DEFINE_ENUM_FLAG_OPERATORS(MDBX_debug_flags)
940
941
955typedef void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt,
956 va_list args) MDBX_CXX17_NOEXCEPT;
957
959#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
960#define MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt *)(intptr_t)-1)
961
968
969typedef void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg,
970 unsigned length) MDBX_CXX17_NOEXCEPT;
971
973 MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size);
974
985typedef void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function,
986 unsigned line) MDBX_CXX17_NOEXCEPT;
987
998
1008LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize);
1009
1011MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
1012
1015#if !((defined(_WIN32) || defined(_WIN64)) && !MDBX_WITHOUT_MSVC_CRT)
1017#endif /* MDBX_WITHOUT_MSVC_CRT */
1018LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line);
1020
1025typedef enum MDBX_env_flags {
1027
1033 MDBX_VALIDATION = UINT32_C(0x00002000),
1034
1051 MDBX_NOSUBDIR = UINT32_C(0x4000),
1052
1069 MDBX_RDONLY = UINT32_C(0x20000),
1070
1099 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1100
1114 MDBX_ACCEDE = UINT32_C(0x40000000),
1115
1145 MDBX_WRITEMAP = UINT32_C(0x80000),
1146
1216 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1217
1219 MDBX_NOTLS MDBX_DEPRECATED_ENUM = MDBX_NOSTICKYTHREADS,
1220
1240 MDBX_NORDAHEAD = UINT32_C(0x800000),
1241
1263 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1264
1276 MDBX_COALESCE MDBX_DEPRECATED_ENUM = UINT32_C(0x2000000),
1277
1300 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1301
1303 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1304
1305 /* SYNC MODES****************************************************************/
1347
1358
1375 MDBX_NOMETASYNC = UINT32_C(0x40000),
1376
1426 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1427
1434
1477
1480DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1481
1482
1486typedef enum MDBX_txn_flags {
1492
1498
1505#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1507#else
1508 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1509#endif
1510
1512 MDBX_TXN_TRY = UINT32_C(0x10000000),
1513
1517
1521
1522 /* Transaction state flags ---------------------------------------------- */
1523
1527 MDBX_TXN_INVALID = INT32_MIN,
1528
1533
1538
1543
1548
1553
1558
1565
1572
1578DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1579
1580
1584typedef enum MDBX_db_flags {
1587
1589 MDBX_REVERSEKEY = UINT32_C(0x02),
1590
1592 MDBX_DUPSORT = UINT32_C(0x04),
1593
1599 MDBX_INTEGERKEY = UINT32_C(0x08),
1600
1603 MDBX_DUPFIXED = UINT32_C(0x10),
1604
1608 MDBX_INTEGERDUP = UINT32_C(0x20),
1609
1611 MDBX_REVERSEDUP = UINT32_C(0x40),
1612
1614 MDBX_CREATE = UINT32_C(0x40000),
1615
1628DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1629
1630
1634typedef enum MDBX_put_flags {
1637
1639 MDBX_NOOVERWRITE = UINT32_C(0x10),
1640
1643 MDBX_NODUPDATA = UINT32_C(0x20),
1644
1649 MDBX_CURRENT = UINT32_C(0x40),
1650
1654 MDBX_ALLDUPS = UINT32_C(0x80),
1655
1658 MDBX_RESERVE = UINT32_C(0x10000),
1659
1662 MDBX_APPEND = UINT32_C(0x20000),
1663
1667 MDBX_APPENDDUP = UINT32_C(0x40000),
1668
1671 MDBX_MULTIPLE = UINT32_C(0x80000)
1673DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1674
1675
1709DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1710
1711
1836
1842typedef enum MDBX_error {
1845
1848
1851
1854
1857
1860
1863
1866
1869 MDBX_PANIC = -30795,
1870
1873
1876
1879
1882
1885
1888
1892
1895
1904
1914
1917
1922
1926
1930
1933
1936
1939 MDBX_BUSY = -30778,
1940
1943
1946
1951
1955
1958
1962
1966
1969
1975
1978
1982
1985 MDBX_OUSTED = -30411,
1986
1989
1990 /* The last of MDBX-added error codes */
1992
1993#if defined(_WIN32) || defined(_WIN64)
1994 MDBX_ENODATA = ERROR_HANDLE_EOF,
1995 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
1996 MDBX_EACCESS = ERROR_ACCESS_DENIED,
1997 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
1998 MDBX_EROFS = ERROR_FILE_READ_ONLY,
1999 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
2000 MDBX_EIO = ERROR_WRITE_FAULT,
2001 MDBX_EPERM = ERROR_INVALID_FUNCTION,
2002 MDBX_EINTR = ERROR_CANCELLED,
2003 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
2004 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
2005 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
2006#else /* Windows */
2007#if defined(ENODATA) || defined(DOXYGEN)
2008 MDBX_ENODATA = ENODATA,
2009#else
2010 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2011#endif /* ENODATA */
2012 MDBX_EINVAL = EINVAL,
2014 MDBX_ENOMEM = ENOMEM,
2015 MDBX_EROFS = EROFS,
2016#if defined(ENOTSUP) || defined(DOXYGEN)
2017 MDBX_ENOSYS = ENOTSUP,
2018#else
2019 MDBX_ENOSYS = ENOSYS,
2020#endif /* ENOTSUP */
2022 MDBX_EPERM = EPERM,
2023 MDBX_EINTR = EINTR,
2025#if defined(EREMOTEIO) || defined(DOXYGEN)
2027 MDBX_EREMOTE = EREMOTEIO,
2028#else
2029 MDBX_EREMOTE = ENOTBLK,
2030#endif /* EREMOTEIO */
2032#endif /* !Windows */
2033} MDBX_error_t;
2034
2039MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated(void) { return MDBX_UNABLE_EXTEND_MAPSIZE; }
2040#define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
2041
2060LIBMDBX_API const char *mdbx_strerror(int errnum);
2061
2086LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2088
2089#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2094LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2095
2100LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen);
2101#endif /* Bit of Windows' madness */
2102
2118
2423
2434LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value);
2435
2446LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue);
2447
2520LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2521
2522#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2526LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2527#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_openW(env, pathname, flags, mode)
2528#else
2529#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_open(env, pathname, flags, mode)
2530#endif /* Windows */
2531
2550
2571
2572#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2577LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode);
2578#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteW(pathname, mode)
2579#else
2580#define mdbx_env_deleteT(pathname, mode) mdbx_env_delete(pathname, mode)
2581#endif /* Windows */
2582
2636LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags);
2637
2692
2693#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2698LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags);
2699#define mdbx_env_copyT(env, dest, flags) mdbx_env_copyW(env, dest, flags)
2700
2706#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathnameW(txn, dest, path)
2707#else
2708#define mdbx_env_copyT(env, dest, flags) mdbx_env_copy(env, dest, flags)
2709#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathname(txn, dest, path)
2710#endif /* Windows */
2711
2737
2762
2767 uint32_t ms_psize;
2769 uint32_t ms_depth;
2771 uint64_t ms_leaf_pages;
2773 uint64_t ms_entries;
2774 uint64_t ms_mod_txnid;
2775};
2776#ifndef __cplusplus
2778typedef struct MDBX_stat MDBX_stat;
2779#endif
2780
2800LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes);
2801
2805MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes) {
2806 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2807}
2808
2813 struct {
2814 uint64_t lower;
2815 uint64_t upper;
2816 uint64_t current;
2817 uint64_t shrink;
2818 uint64_t grow;
2820 uint64_t mi_mapsize;
2821 uint64_t mi_dxb_fsize;
2823 uint64_t mi_last_pgno;
2828 uint32_t mi_maxreaders;
2829 uint32_t mi_numreaders;
2832 uint32_t mi_sys_upcblk;
2833 uint32_t mi_sys_ioblk;
2834
2843 struct {
2844 struct {
2845 uint64_t x, y;
2846 } current, meta[3];
2848
2865 uint32_t mi_mode;
2866
2872 struct {
2873 uint64_t newly;
2874 uint64_t cow;
2875 uint64_t clone;
2877 uint64_t split;
2878 uint64_t merge;
2879 uint64_t spill;
2880 uint64_t unspill;
2881 uint64_t wops;
2883 uint64_t prefault;
2884 uint64_t mincore;
2885 uint64_t msync;
2886 uint64_t fsync;
2888
2889 /* GUID of the database DXB file. */
2890 struct {
2891 uint64_t x, y;
2893};
2894#ifndef __cplusplus
2896typedef struct MDBX_envinfo MDBX_envinfo;
2897#endif
2898
2919LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes);
2923MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes) {
2924 return mdbx_env_info_ex(env, NULL, info, bytes);
2925}
2926
2963LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2964
2968inline int mdbx_env_sync(MDBX_env * env) { return mdbx_env_sync_ex(env, true, false); }
2969
2973inline int mdbx_env_sync_poll(MDBX_env * env) { return mdbx_env_sync_ex(env, false, true); }
2974
2998inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
2999 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
3000}
3001
3016inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
3017 int rc = MDBX_EINVAL;
3018 if (threshold) {
3019 uint64_t proxy = 0;
3020 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3021#ifdef assert
3022 assert(proxy <= SIZE_MAX);
3023#endif /* assert */
3024 *threshold = (size_t)proxy;
3025 }
3026 return rc;
3027}
3028
3059inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3060 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3061}
3062
3079inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3080 int rc = MDBX_EINVAL;
3081 if (period_seconds_16dot16) {
3082 uint64_t proxy = 0;
3083 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3084#ifdef assert
3085 assert(proxy <= UINT32_MAX);
3086#endif /* assert */
3087 *period_seconds_16dot16 = (unsigned)proxy;
3088 }
3089 return rc;
3090}
3091
3131LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3132
3136inline int mdbx_env_close(MDBX_env * env) { return mdbx_env_close_ex(env, false); }
3137
3138#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3216#endif /* Windows */
3217
3266DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3267
3268
3300 unsigned timeout_seconds_16dot16);
3301
3323
3334LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3335
3349LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3350
3351#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3356LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3357#define mdbx_env_get_pathT(env, dest) mdbx_env_get_pathW(env, dest)
3358#else
3359#define mdbx_env_get_pathT(env, dest) mdbx_env_get_path(env, dest)
3360#endif /* Windows */
3361
3375
3572LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper,
3573 intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize);
3574
3577MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3578 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3579}
3580
3596LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy);
3597
3601
3605
3610
3615
3621
3626
3632
3637
3643 MDBX_db_flags_t flags);
3644
3651
3656
3680inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3681 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3682}
3683
3695inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3696 int rc = MDBX_EINVAL;
3697 if (readers) {
3698 uint64_t proxy = 0;
3699 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3700 *readers = (unsigned)proxy;
3701 }
3702 return rc;
3703}
3704
3726inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3727 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3728}
3729
3740inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3741 int rc = MDBX_EINVAL;
3742 if (dbs) {
3743 uint64_t proxy = 0;
3744 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3745 *dbs = (MDBX_dbi)proxy;
3746 }
3747 return rc;
3748}
3749
3755
3770LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages);
3771
3782
3793
3798
3810
3822
3833
3843
3904 void *context);
3905
3960inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) {
3961 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3962}
3963
3975
3987
3994 uint64_t txn_id;
3995
4001
4005
4008
4012
4020
4027
4034};
4035#ifndef __cplusplus
4037typedef struct MDBX_txn_info MDBX_txn_info;
4038#endif
4039
4053LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt);
4054
4060
4071
4084
4092 uint32_t preparation;
4096 uint32_t audit;
4099 uint32_t write;
4102 uint32_t sync;
4104 uint32_t ending;
4106 uint32_t whole;
4108 uint32_t gc_cputime;
4109
4117 struct {
4120 uint32_t wloops;
4122 uint32_t coalescences;
4125 uint32_t wipes;
4129 uint32_t flushes;
4133 uint32_t kicks;
4134
4137 uint32_t work_counter;
4140 uint32_t work_rtime_monotonic;
4144 uint32_t work_xtime_cpu;
4147 uint32_t work_rsteps;
4150 uint32_t work_xpages;
4153 uint32_t work_majflt;
4154
4157 uint32_t self_counter;
4160 uint32_t self_rtime_monotonic;
4164 uint32_t self_xtime_cpu;
4167 uint32_t self_rsteps;
4170 uint32_t self_xpages;
4173 uint32_t self_majflt;
4174 /* Для разборок с pnl_merge() */
4175 struct {
4176 uint32_t time;
4177 uint64_t volume;
4178 uint32_t calls;
4179 } pnl_merge_work, pnl_merge_self;
4181};
4182#ifndef __cplusplus
4185#endif
4186
4193
4235inline int mdbx_txn_commit(MDBX_txn * txn) { return mdbx_txn_commit_ex(txn, NULL); }
4236
4271
4284
4319
4363LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4364
4406LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4407
4429
4441 uint64_t x, y, z, v;
4442};
4443#ifndef __cplusplus
4445typedef struct MDBX_canary MDBX_canary;
4446#endif
4447
4467
4479
4500typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4501
4595LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi);
4599
4618MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi,
4619 MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4622MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4623 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4624
4640LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4644
4664typedef int(MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4665 const struct MDBX_stat *stat, MDBX_dbi dbi) MDBX_CXX17_NOEXCEPT;
4666
4688
4701
4703
4704MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
4705
4707
4708MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
4709
4710MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
4711 return UINT64_C(0x8000000000000000) + i64;
4712}
4713
4714MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
4715 return UINT32_C(0x80000000) + i32;
4716}
4717
4718
4725
4727
4729
4731
4734
4749LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes);
4750
4766LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask);
4767
4771typedef enum MDBX_dbi_state {
4781DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
4782
4783
4794LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state);
4799inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
4800 unsigned state;
4801 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
4802}
4803
4830
4842LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
4843
4878LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data);
4879
4910LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count);
4911
4941
5023LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags);
5024
5068LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data,
5069 MDBX_put_flags_t flags);
5070
5071typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes);
5072LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data,
5073 MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver,
5074 void *preserver_context);
5075
5101LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data);
5102
5126
5137
5148
5179
5206
5220
5252
5273
5296
5319LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count);
5320
5341inline int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind) {
5342 return mdbx_txn_release_all_cursors_ex(txn, unbind, NULL);
5343}
5344
5370
5376
5382
5394
5416LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival);
5417
5450
5465
5495typedef int(MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) MDBX_CXX17_NOEXCEPT;
5496
5565LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context,
5566 MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg);
5567
5653 MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value,
5654 MDBX_cursor_op turn_op, void *arg);
5655
5697LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit,
5698 MDBX_cursor_op op);
5699
5781
5813
5831LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count);
5832
5855LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes);
5856
5870
5883
5896
5909
5922
5947
5967LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items);
5968
5990 ptrdiff_t *distance_items);
5991
6016LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key,
6017 const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data,
6018 ptrdiff_t *distance_items);
6019
6022#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
6023
6058
6079LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment);
6080
6097 const MDBX_val *b);
6098
6102
6119 const MDBX_val *b);
6120
6124
6150typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid,
6151 uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6152
6165
6175
6188MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent);
6189
6209
6224
6298typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6299 unsigned gap, size_t space, int retry) MDBX_CXX17_NOEXCEPT;
6300
6320
6334
6340
6344LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
6345
6350
6360LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable);
6361
6362#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6367LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta,
6368 bool writeable);
6369#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6370 mdbx_env_open_for_recoveryW(env, pathname, target_mets, writeable)
6371#else
6372#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6373 mdbx_env_open_for_recovery(env, pathname, target_mets, writeable)
6374#endif /* Windows */
6375
6381LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
6382
6414LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes);
6415#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6420LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes);
6421#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfoW(pathname, info, bytes)
6422#else
6423#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfo(pathname, info, bytes)
6424#endif /* Windows */
6425
6449DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
6450
6451
6469
6487
6490typedef struct MDBX_chk_line {
6491 struct MDBX_chk_context *ctx;
6493 char *begin, *end, *out;
6495
6498typedef struct MDBX_chk_issue {
6499 struct MDBX_chk_issue *next;
6500 size_t count;
6501 const char *caption;
6503
6506typedef struct MDBX_chk_scope {
6508 struct MDBX_chk_internal *internal;
6509 const void *object;
6513 union {
6514 void *ptr;
6515 size_t number;
6516 } usr_z, usr_v, usr_o;
6518
6522typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
6523
6529 struct {
6530 size_t begin, end, amount, count;
6532};
6533
6537typedef struct MDBX_chk_table {
6539
6541#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
6543#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
6545#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
6546
6549 int id;
6550
6552 struct {
6553 size_t all, empty, broken;
6554 size_t branch, leaf;
6556 } pages;
6576
6598
6614typedef struct MDBX_chk_callbacks {
6616 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt,
6617 va_list args);
6620 void (*issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue,
6621 const char *extra_fmt, va_list extra_args);
6623 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err);
6625
6626 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number,
6627 const MDBX_val *key, const MDBX_val *value);
6628
6631
6635 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
6636 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
6637 void (*print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix);
6639
6670 const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity,
6671 unsigned timeout_seconds_16dot16);
6672
6679
6680LIBMDBX_API const char *mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer,
6681 size_t buffer_size);
6682
6683LIBMDBX_API const char *mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size);
6684
6686
6688
6689#ifdef __cplusplus
6690} /* extern "C" */
6691#endif
6692
6693#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:2820
uint32_t wipes
Количество уничтожений предыдущих надежных/устойчивых точек фиксации при работе в режиме MDBX_UTTERLY...
uint64_t txn_space_dirty
Definition mdbx.h:4033
struct MDBX_envinfo::@012005163333303136244023145022271211024347140371 mi_geo
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4108
const char * describe
uint32_t mi_dxb_pagesize
Definition mdbx.h:2830
uint32_t mi_maxreaders
Definition mdbx.h:2828
uint64_t v
Definition mdbx.h:4441
uint32_t coalescences
Количество итераций слияния записей GC.
uint32_t mi_numreaders
Definition mdbx.h:2829
uint16_t patch
Definition mdbx.h:619
const char * metadata
Definition mdbx.h:640
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2856
uint32_t self_xpages
Количество запросов на выделение последовательностей страниц для самой GC.
uint16_t major
Definition mdbx.h:617
uint64_t txn_reader_lag
Definition mdbx.h:4000
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2827
uint64_t txn_space_leftover
Definition mdbx.h:4026
struct MDBX_envinfo::@366225332126364017271247035205240304242123014254 mi_pgop_stat
uint64_t txn_space_used
Definition mdbx.h:4004
const char * datetime
Definition mdbx.h:635
uint64_t mi_recent_txnid
Definition mdbx.h:2824
uint64_t mi_autosync_threshold
Definition mdbx.h:2852
const char * semver_prerelease
Definition mdbx.h:621
uint32_t wloops
Количество итераций обновления GC, больше 1 если были повторы/перезапуски.
uint64_t ms_branch_pages
Definition mdbx.h:2770
uint64_t ms_entries
Definition mdbx.h:2773
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4094
uint16_t minor
Definition mdbx.h:618
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2862
uint64_t y
Definition mdbx.h:4441
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:4102
uint32_t mi_sys_ioblk
Definition mdbx.h:2833
uint64_t txn_space_limit_soft
Definition mdbx.h:4007
uint32_t mi_mode
Definition mdbx.h:2865
const char * options
Definition mdbx.h:637
uint64_t txn_id
Definition mdbx.h:3994
const char * sourcery
Definition mdbx.h:628
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2825
uint64_t ms_overflow_pages
Definition mdbx.h:2772
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:4092
uint32_t mi_sys_upcblk
Definition mdbx.h:2832
uint64_t z
Definition mdbx.h:4441
uint64_t txn_space_limit_hard
Definition mdbx.h:4011
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4106
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:2827
uint32_t ms_psize
Definition mdbx.h:2767
uint32_t kicks
Количество обращений к механизму Handle-Slow-Readers во избежания приращения БД.
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4096
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:4099
uint64_t txn_space_retired
Definition mdbx.h:4019
uint32_t ms_depth
Definition mdbx.h:2769
uint64_t mi_dxb_fallocated
Definition mdbx.h:2822
uint64_t mi_last_pgno
Definition mdbx.h:2823
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:4104
uint64_t ms_mod_txnid
Definition mdbx.h:2774
uint32_t work_rsteps
Количество итераций поиска внутри GC при выделении страниц ради данных пользователя.
const char * datetime
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2826
uint64_t ms_leaf_pages
Definition mdbx.h:2771
uint64_t mi_dxb_fsize
Definition mdbx.h:2821
uint64_t x
Definition mdbx.h:4441
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2859
uint64_t mi_unsync_volume
Definition mdbx.h:2850
uint32_t mi_sys_pagesize
Definition mdbx.h:2831
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:5071
#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:4440
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4089
Information about the environment.
Definition mdbx.h:2812
Statistics for a table in the environment.
Definition mdbx.h:2766
Information about the transaction.
Definition mdbx.h:3991
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:1634
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:4500
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:5495
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:1671
@ MDBX_ALLDUPS
Definition mdbx.h:1654
@ MDBX_CURRENT
Definition mdbx.h:1649
@ MDBX_APPENDDUP
Definition mdbx.h:1667
@ MDBX_NODUPDATA
Definition mdbx.h:1643
@ MDBX_APPEND
Definition mdbx.h:1662
@ MDBX_UPSERT
Definition mdbx.h:1636
@ MDBX_RESERVE
Definition mdbx.h:1658
@ MDBX_NOOVERWRITE
Definition mdbx.h:1639
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:5341
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:1715
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:1792
@ MDBX_SEEK_AND_GET_MULTIPLE
Definition mdbx.h:1834
@ MDBX_GET_CURRENT
Definition mdbx.h:1730
@ MDBX_GET_BOTH
Definition mdbx.h:1723
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1811
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1727
@ MDBX_SET_KEY
Definition mdbx.h:1770
@ MDBX_FIRST_DUP
Definition mdbx.h:1720
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1810
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1735
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1821
@ MDBX_NEXT_NODUP
Definition mdbx.h:1755
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1818
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1819
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1826
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1778
@ MDBX_SET_RANGE
Definition mdbx.h:1773
@ MDBX_LAST_DUP
Definition mdbx.h:1741
@ MDBX_PREV
Definition mdbx.h:1758
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1828
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1829
@ MDBX_LAST
Definition mdbx.h:1738
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1809
@ MDBX_PREV_DUP
Definition mdbx.h:1761
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1817
@ MDBX_SET
Definition mdbx.h:1767
@ MDBX_NEXT
Definition mdbx.h:1744
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1812
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1825
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1752
@ MDBX_PREV_NODUP
Definition mdbx.h:1764
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1827
@ MDBX_NEXT_DUP
Definition mdbx.h:1747
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1820
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1806
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1813
@ MDBX_FIRST
Definition mdbx.h:1717
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:1584
@ MDBX_INTEGERDUP
Definition mdbx.h:1608
@ MDBX_DB_ACCEDE
Definition mdbx.h:1626
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1586
@ MDBX_REVERSEKEY
Definition mdbx.h:1589
@ MDBX_DUPFIXED
Definition mdbx.h:1603
@ MDBX_INTEGERKEY
Definition mdbx.h:1599
@ MDBX_REVERSEDUP
Definition mdbx.h:1611
@ MDBX_CREATE
Definition mdbx.h:1614
@ MDBX_DUPSORT
Definition mdbx.h:1592
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:969
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:985
MDBX_log_level_t
Definition mdbx.h:843
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:902
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:955
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:885
@ MDBX_LOG_WARN
Definition mdbx.h:859
@ MDBX_LOG_TRACE
Definition mdbx.h:880
@ MDBX_LOG_DEBUG
Definition mdbx.h:875
@ MDBX_LOG_FATAL
Definition mdbx.h:847
@ MDBX_LOG_ERROR
Definition mdbx.h:853
@ MDBX_LOG_NOTICE
Definition mdbx.h:865
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:892
@ MDBX_LOG_VERBOSE
Definition mdbx.h:870
@ MDBX_DBG_ASSERT
Definition mdbx.h:908
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:930
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:926
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:923
@ MDBX_DBG_NONE
Definition mdbx.h:903
@ MDBX_DBG_DUMP
Definition mdbx.h:920
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:937
@ MDBX_DBG_AUDIT
Definition mdbx.h:912
@ MDBX_DBG_JITTER
Definition mdbx.h:916
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:6298
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1842
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:1869
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1856
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1957
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1903
@ MDBX_EACCESS
Definition mdbx.h:2013
@ MDBX_EIO
Definition mdbx.h:2021
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1862
@ MDBX_TXN_FULL
Definition mdbx.h:1887
@ MDBX_DUPLICATED_CLK
Definition mdbx.h:1977
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1872
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1954
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1968
@ MDBX_EREMOTE
Definition mdbx.h:2027
@ MDBX_TOO_LARGE
Definition mdbx.h:1961
@ MDBX_EBADSIGN
Definition mdbx.h:1950
@ MDBX_CURSOR_FULL
Definition mdbx.h:1891
@ MDBX_ENOFILE
Definition mdbx.h:2024
@ MDBX_BAD_TXN
Definition mdbx.h:1921
@ MDBX_ENODATA
Definition mdbx.h:2008
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1935
@ MDBX_CORRUPTED
Definition mdbx.h:1865
@ MDBX_EPERM
Definition mdbx.h:2022
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1965
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1974
@ MDBX_SUCCESS
Definition mdbx.h:1844
@ MDBX_NOTFOUND
Definition mdbx.h:1859
@ MDBX_RESULT_TRUE
Definition mdbx.h:1850
@ MDBX_INVALID
Definition mdbx.h:1875
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1925
@ MDBX_BUSY
Definition mdbx.h:1939
@ MDBX_OUSTED
Definition mdbx.h:1985
@ MDBX_DBS_FULL
Definition mdbx.h:1881
@ MDBX_EINVAL
Definition mdbx.h:2012
@ MDBX_BAD_RSLOT
Definition mdbx.h:1916
@ MDBX_ENOMEM
Definition mdbx.h:2014
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1942
@ MDBX_RESULT_FALSE
Definition mdbx.h:1847
@ MDBX_EINTR
Definition mdbx.h:2023
@ MDBX_READERS_FULL
Definition mdbx.h:1884
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:1991
@ MDBX_BAD_DBI
Definition mdbx.h:1929
@ MDBX_KEYEXIST
Definition mdbx.h:1853
@ MDBX_DANGLING_DBI
Definition mdbx.h:1981
@ MDBX_EDEADLK
Definition mdbx.h:2031
@ MDBX_PAGE_FULL
Definition mdbx.h:1894
@ MDBX_MAP_FULL
Definition mdbx.h:1878
@ MDBX_PROBLEM
Definition mdbx.h:1932
@ MDBX_ENOSYS
Definition mdbx.h:2017
@ MDBX_EMULTIVAL
Definition mdbx.h:1945
@ MDBX_EROFS
Definition mdbx.h:2015
@ MDBX_MVCC_RETARDED
Definition mdbx.h:1988
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1913
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:1678
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:2968
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:2973
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:2535
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:1697
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1679
@ MDBX_CP_COMPACT
Definition mdbx.h:1683
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1702
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1693
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1686
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1689
@ MDBX_CP_OVERWRITE
Definition mdbx.h:1706
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2548
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2542
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2545
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:3136
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1025
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:1240
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1026
@ MDBX_COALESCE
Definition mdbx.h:1276
@ MDBX_NOMETASYNC
Definition mdbx.h:1375
@ MDBX_LIFORECLAIM
Definition mdbx.h:1300
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1426
@ MDBX_NOTLS
Definition mdbx.h:1219
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1357
@ MDBX_PAGEPERTURB
Definition mdbx.h:1303
@ MDBX_WRITEMAP
Definition mdbx.h:1145
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1216
@ MDBX_EXCLUSIVE
Definition mdbx.h:1099
@ MDBX_NOMEMINIT
Definition mdbx.h:1263
@ MDBX_MAPASYNC
Definition mdbx.h:1433
@ MDBX_ACCEDE
Definition mdbx.h:1114
@ MDBX_NOSUBDIR
Definition mdbx.h:1051
@ MDBX_RDONLY
Definition mdbx.h:1069
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1476
@ MDBX_VALIDATION
Definition mdbx.h:1033
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:3577
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3726
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:3059
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2122
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:2998
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3222
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:3680
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:2227
@ MDBX_opt_subpage_room_threshold
Задаёт в % минимальный объём свободного места на основной странице, при отсутствии которого вложенные...
Definition mdbx.h:2400
@ MDBX_opt_subpage_limit
Задаёт в % максимальный размер вложенных страниц, используемых для размещения небольшого количества м...
Definition mdbx.h:2394
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2223
@ MDBX_opt_prefer_waf_insteadof_balance
Управляет выбором между стремлением к равномерности наполнения страниц, либо уменьшением количества и...
Definition mdbx.h:2379
@ 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:2327
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2131
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2294
@ MDBX_opt_subpage_reserve_prereq
Задаёт в % минимальный объём свободного места на основной странице, при наличии которого,...
Definition mdbx.h:2416
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2154
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2259
@ 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:2282
@ 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:2194
@ 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:2181
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2148
@ MDBX_opt_subpage_reserve_limit
Задаёт в % ограничение резервирования места на вложенных страницах.
Definition mdbx.h:2421
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2243
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2160
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2208
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2322
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2354
@ MDBX_warmup_touchlimit
Definition mdbx.h:3261
@ MDBX_warmup_force
Definition mdbx.h:3231
@ MDBX_warmup_oomsafe
Definition mdbx.h:3238
@ MDBX_warmup_release
Definition mdbx.h:3264
@ MDBX_warmup_lock
Definition mdbx.h:3253
@ MDBX_warmup_default
Definition mdbx.h:3225
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:3695
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:3079
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:4799
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:2923
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:3016
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:3604
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:4771
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:3600
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:6150
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:3740
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:2805
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:4664
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:4773
@ MDBX_DBI_FRESH
Definition mdbx.h:4777
@ MDBX_DBI_STALE
Definition mdbx.h:4775
@ MDBX_DBI_CREAT
Definition mdbx.h:4779
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:4235
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:1486
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:3960
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:1497
@ MDBX_TXN_ERROR
Definition mdbx.h:1537
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1516
@ MDBX_TXN_SPILLS
Definition mdbx.h:1547
@ MDBX_TXN_OUSTED
Definition mdbx.h:1571
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1552
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1506
@ MDBX_TXN_INVALID
Definition mdbx.h:1527
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1576
@ MDBX_TXN_PARKED
Definition mdbx.h:1557
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1520
@ MDBX_TXN_DIRTY
Definition mdbx.h:1542
@ MDBX_TXN_READWRITE
Definition mdbx.h:1491
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1564
@ MDBX_TXN_TRY
Definition mdbx.h:1512
@ MDBX_TXN_FINISHED
Definition mdbx.h:1532
MDBX_chk_severity_t verbosity
Definition mdbx.h:6511
MDBX_txn * txn
Definition mdbx.h:6582
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:6620
struct MDBX_chk_histogram tree_density
Histogram of branch and leaf pages filling in percents.
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:6637
size_t pad
Definition mdbx.h:6528
void(* print_done)(MDBX_chk_line_t *)
Definition mdbx.h:6634
struct MDBX_chk_internal * internal
Definition mdbx.h:6580
uint8_t scope_nesting
Definition mdbx.h:6584
char * end
Definition mdbx.h:6493
uint8_t scope_depth
Definition mdbx.h:6492
struct MDBX_chk_histogram key_len
Keys length histogram.
struct MDBX_chk_histogram large_or_nested_density
Histogram of nested tree(s) branch and leaf pages filling in percents.
int(* stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t)
Definition mdbx.h:6629
size_t ones
Definition mdbx.h:6528
int(* stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err)
Definition mdbx.h:6630
int(* table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err)
Definition mdbx.h:6623
void(* print_format)(MDBX_chk_line_t *, const char *fmt, va_list args)
Definition mdbx.h:6636
struct MDBX_chk_internal * internal
Definition mdbx.h:6508
char * begin
Definition mdbx.h:6493
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:6616
size_t subtotal_issues
Definition mdbx.h:6512
struct MDBX_chk_histogram nested_height
Histogram of nested trees height, span length for GC.
uint8_t severity
Definition mdbx.h:6492
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:6538
void(* scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner)
Definition mdbx.h:6619
struct MDBX_chk_context * ctx
Definition mdbx.h:6491
MDBX_db_flags_t flags
Definition mdbx.h:6548
int(* scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, int err)
Definition mdbx.h:6618
void(* print_flush)(MDBX_chk_line_t *)
Definition mdbx.h:6633
struct MDBX_chk_issue * next
Definition mdbx.h:6499
struct MDBX_chk_histogram large_pages
Histogram of large/overflow pages length.
char * out
Definition mdbx.h:6493
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:6635
const MDBX_chk_table_t *const * tables
const void * object
Definition mdbx.h:6509
size_t count
Definition mdbx.h:6528
const char * caption
Definition mdbx.h:6501
MDBX_chk_stage_t stage
Definition mdbx.h:6510
struct MDBX_chk_histogram height
Tree deep histogram.
struct MDBX_chk_histogram multival
Number of multi-values (aka duplicates) histogram.
MDBX_env * env
Definition mdbx.h:6581
uint8_t empty
Definition mdbx.h:6492
size_t amount
Definition mdbx.h:6528
MDBX_chk_scope_t * scope
Definition mdbx.h:6583
MDBX_chk_issue_t * issues
Definition mdbx.h:6507
size_t payload_bytes
Definition mdbx.h:6551
size_t count
Definition mdbx.h:6500
MDBX_val name
Definition mdbx.h:6547
size_t lost_bytes
Definition mdbx.h:6551
bool(* check_break)(MDBX_chk_context_t *ctx)
Definition mdbx.h:6615
void(* table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table)
Definition mdbx.h:6624
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:6626
int id
Definition mdbx.h:6549
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)
Проверяет целостность базы данных.
LIBMDBX_API const char * mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer, size_t buffer_size)
MDBX_chk_stage_t
Стадии проверки, сообщаемые через обратные вызовы при проверке целостности базы данных.
Definition mdbx.h:6473
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
LIBMDBX_API const char * mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size)
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение...
Definition mdbx.h:6522
MDBX_chk_flags_t
Флаги/опции для проверки целостности базы данных.
Definition mdbx.h:6430
MDBX_chk_severity_t
Уровни логирование/детализации информации, поставляемой через обратные вызовы при проверке целостност...
Definition mdbx.h:6454
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:6479
@ MDBX_chk_init
Definition mdbx.h:6475
@ MDBX_chk_finalize
Definition mdbx.h:6485
@ MDBX_chk_space
Definition mdbx.h:6480
@ MDBX_chk_lock
Definition mdbx.h:6476
@ MDBX_chk_none
Definition mdbx.h:6474
@ MDBX_chk_maindb
Definition mdbx.h:6481
@ MDBX_chk_unlock
Definition mdbx.h:6484
@ MDBX_chk_meta
Definition mdbx.h:6477
@ MDBX_chk_conclude
Definition mdbx.h:6483
@ MDBX_chk_tree
Definition mdbx.h:6478
@ MDBX_chk_tables
Definition mdbx.h:6482
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:6439
@ MDBX_CHK_READWRITE
Definition mdbx.h:6436
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:6432
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:6442
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:6447
@ MDBX_chk_processing
Definition mdbx.h:6463
@ MDBX_chk_result
Definition mdbx.h:6461
@ MDBX_chk_details
Definition mdbx.h:6466
@ MDBX_chk_extra
Definition mdbx.h:6467
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:6455
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:6456
@ MDBX_chk_notice
Definition mdbx.h:6460
@ MDBX_chk_resolution
Definition mdbx.h:6462
@ MDBX_chk_warning
Definition mdbx.h:6459
@ MDBX_chk_fatal
Definition mdbx.h:6457
@ MDBX_chk_info
Definition mdbx.h:6464
@ MDBX_chk_error
Definition mdbx.h:6458
@ MDBX_chk_verbose
Definition mdbx.h:6465
Набор функций обратного вызова используемых при проверке целостности базы данных.
Definition mdbx.h:6614
Контекст проверки целостности базы данных.
Definition mdbx.h:6579
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД.
Definition mdbx.h:6527
Проблема обнаруженная при проверке целостности базы данных.
Definition mdbx.h:6498
Виртуальная строка отчета, формируемого при проверке целостности базы данных.
Definition mdbx.h:6490
Иерархический контекст при проверке целостности базы данных.
Definition mdbx.h:6506
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных.
Definition mdbx.h:6537
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:4710
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:4714
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)