libmdbx 0.13.6.169 (2025-04-22T15:56:02+03:00)
One of the fastest compact embeddable key-value ACID storage engine without WAL.
 
Loading...
Searching...
No Matches
mdbx.h
Go to the documentation of this file.
1
37
38#pragma once
39#ifndef LIBMDBX_H
40#define LIBMDBX_H
41
42#if defined(__riscv) || defined(__riscv__) || defined(__RISCV) || defined(__RISCV__)
43#warning "The RISC-V architecture is intentionally insecure by design. \
44 Please delete this admonition at your own risk, \
45 if you make such decision informed and consciously. \
46 Refer to https://clck.ru/32d9xH for more information."
47#endif /* RISC-V */
48
49#ifdef _MSC_VER
50#pragma warning(push, 1)
51#pragma warning(disable : 4548) /* expression before comma has no effect; \
52 expected expression with side - effect */
53#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
54 * semantics are not enabled. Specify /EHsc */
55#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
56 * mode specified; termination on exception is \
57 * not guaranteed. Specify /EHsc */
58#endif /* _MSC_VER (warnings) */
59
60/* *INDENT-OFF* */
61/* clang-format off */
144/* *INDENT-ON* */
145/* clang-format on */
146
147#include <stdarg.h>
148#include <stddef.h>
149#include <stdint.h>
150#if !defined(NDEBUG) && !defined(assert)
151#include <assert.h>
152#endif /* NDEBUG */
153
154#if defined(_WIN32) || defined(_WIN64)
155#include <windows.h>
156#include <winnt.h>
157#ifndef __mode_t_defined
158typedef unsigned short mdbx_mode_t;
159#else
160typedef mode_t mdbx_mode_t;
161#endif /* __mode_t_defined */
162typedef HANDLE mdbx_filehandle_t;
163typedef DWORD mdbx_pid_t;
164typedef DWORD mdbx_tid_t;
165#else /* Windows */
166#include <errno.h> /* for error codes */
167#include <pthread.h> /* for pthread_t */
168#include <sys/types.h> /* for pid_t */
169#include <sys/uio.h> /* for struct iovec */
170#define HAVE_STRUCT_IOVEC 1
172typedef pid_t mdbx_pid_t;
173typedef pthread_t mdbx_tid_t;
174typedef mode_t mdbx_mode_t;
175#endif /* !Windows */
176
177#ifdef _MSC_VER
178#pragma warning(pop)
179#endif
180
185
186/*----------------------------------------------------------------------------*/
187
188#ifndef __has_attribute
189#define __has_attribute(x) (0)
190#endif /* __has_attribute */
191
192#ifndef __has_c_attribute
193#define __has_c_attribute(x) (0)
194#define __has_c_attribute_qualified(x) 0
195#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
196#define __has_c_attribute_qualified(x) 0
197#elif defined(_MSC_VER)
198/* MSVC don't support `namespace::attr` syntax */
199#define __has_c_attribute_qualified(x) 0
200#else
201#define __has_c_attribute_qualified(x) __has_c_attribute(x)
202#endif /* __has_c_attribute */
203
204#ifndef __has_cpp_attribute
205#define __has_cpp_attribute(x) 0
206#define __has_cpp_attribute_qualified(x) 0
207#elif defined(_MSC_VER) || (__clang__ && __clang__ < 14)
208/* MSVC don't support `namespace::attr` syntax */
209#define __has_cpp_attribute_qualified(x) 0
210#else
211#define __has_cpp_attribute_qualified(x) __has_cpp_attribute(x)
212#endif /* __has_cpp_attribute */
213
214#ifndef __has_C23_or_CXX_attribute
215#if defined(__cplusplus)
216#define __has_C23_or_CXX_attribute(x) __has_cpp_attribute_qualified(x)
217#else
218#define __has_C23_or_CXX_attribute(x) __has_c_attribute_qualified(x)
219#endif
220#endif /* __has_C23_or_CXX_attribute */
221
222#ifndef __has_feature
223#define __has_feature(x) (0)
224#define __has_exceptions_disabled (0)
225#elif !defined(__has_exceptions_disabled)
226#define __has_exceptions_disabled (__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions))
227#endif /* __has_feature */
228
229#ifndef __has_extension
230#define __has_extension(x) __has_feature(x)
231#endif /* __has_extension */
232
233#ifndef __has_builtin
234#define __has_builtin(x) (0)
235#endif /* __has_builtin */
236
243#if defined(DOXYGEN)
244#define MDBX_PURE_FUNCTION [[gnu::pure]]
245#elif __has_C23_or_CXX_attribute(gnu::pure)
246#define MDBX_PURE_FUNCTION [[gnu::pure]]
247#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
248 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
249 __has_exceptions_disabled)
250#define MDBX_PURE_FUNCTION __attribute__((__pure__))
251#else
252#define MDBX_PURE_FUNCTION
253#endif /* MDBX_PURE_FUNCTION */
254
258#if defined(DOXYGEN)
259#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
260#elif __has_C23_or_CXX_attribute(gnu::pure)
261#if __has_C23_or_CXX_attribute(gnu::nothrow)
262#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
263#else
264#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
265#endif
266#elif defined(__GNUC__) || (__has_attribute(__pure__) && __has_attribute(__nothrow__))
267#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
268#elif __has_cpp_attribute(pure)
269#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
270#else
271#define MDBX_NOTHROW_PURE_FUNCTION
272#endif /* MDBX_NOTHROW_PURE_FUNCTION */
273
284#if defined(DOXYGEN)
285#define MDBX_CONST_FUNCTION [[gnu::const]]
286#elif __has_C23_or_CXX_attribute(gnu::const)
287#define MDBX_CONST_FUNCTION [[gnu::const]]
288#elif (defined(__GNUC__) || __has_attribute(__const__)) && \
289 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
290 __has_exceptions_disabled)
291#define MDBX_CONST_FUNCTION __attribute__((__const__))
292#else
293#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
294#endif /* MDBX_CONST_FUNCTION */
295
299#if defined(DOXYGEN)
300#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
301#elif __has_C23_or_CXX_attribute(gnu::const)
302#if __has_C23_or_CXX_attribute(gnu::nothrow)
303#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
304#else
305#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const]]
306#endif
307#elif defined(__GNUC__) || (__has_attribute(__const__) && __has_attribute(__nothrow__))
308#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
309#elif __has_cpp_attribute_qualified(const)
310#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
311#else
312#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
313#endif /* MDBX_NOTHROW_CONST_FUNCTION */
314
318#ifndef MDBX_DEPRECATED
319#ifdef __deprecated
320#define MDBX_DEPRECATED __deprecated
321#elif defined(DOXYGEN) || ((!defined(__GNUC__) || (defined(__clang__) && __clang__ > 19) || __GNUC__ > 5) && \
322 ((defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
323 __has_cpp_attribute(deprecated) >= 201309L) || \
324 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202304L)))
325#define MDBX_DEPRECATED [[deprecated]]
326#elif (defined(__GNUC__) && __GNUC__ > 5) || \
327 (__has_attribute(__deprecated__) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 5))
328#define MDBX_DEPRECATED __attribute__((__deprecated__))
329#elif defined(_MSC_VER)
330#define MDBX_DEPRECATED __declspec(deprecated)
331#else
332#define MDBX_DEPRECATED
333#endif
334#endif /* MDBX_DEPRECATED */
335
336#ifndef MDBX_DEPRECATED_ENUM
337#ifdef __deprecated_enum
338#define MDBX_DEPRECATED_ENUM __deprecated_enum
339#elif defined(DOXYGEN) || \
340 (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
341 __has_cpp_attribute(deprecated) >= 201309L))
342#define MDBX_DEPRECATED_ENUM MDBX_DEPRECATED
343#else
344#define MDBX_DEPRECATED_ENUM /* avoid madness MSVC */
345#endif
346#endif /* MDBX_DEPRECATED_ENUM */
347
348#ifndef __dll_export
349#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
350 defined(__MINGW64__)
351#if defined(__GNUC__) || __has_attribute(__dllexport__)
352#define __dll_export __attribute__((__dllexport__))
353#elif defined(_MSC_VER)
354#define __dll_export __declspec(dllexport)
355#else
356#define __dll_export
357#endif
358#elif defined(__GNUC__) || __has_attribute(__visibility__)
359#define __dll_export __attribute__((__visibility__("default")))
360#else
361#define __dll_export
362#endif
363#endif /* __dll_export */
364
365#ifndef __dll_import
366#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
367 defined(__MINGW64__)
368#if defined(__GNUC__) || __has_attribute(__dllimport__)
369#define __dll_import __attribute__((__dllimport__))
370#elif defined(_MSC_VER)
371#define __dll_import __declspec(dllimport)
372#else
373#define __dll_import
374#endif
375#else
376#define __dll_import
377#endif
378#endif /* __dll_import */
379
384#if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
385#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
386 /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
387 /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
388#else
389#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
390#endif /* LIBMDBX_INLINE_API */
391
393#ifndef MDBX_STRINGIFY
394#define MDBX_STRINGIFY_HELPER(x) #x
395#define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
396#endif /* MDBX_STRINGIFY */
397
398/*----------------------------------------------------------------------------*/
399
400#ifndef __cplusplus
401#ifndef bool
402#define bool _Bool
403#endif
404#ifndef true
405#define true (1)
406#endif
407#ifndef false
408#define false (0)
409#endif
410#endif /* bool without __cplusplus */
411
413#if defined(DOXYGEN)
414#define MDBX_CXX17_NOEXCEPT noexcept
415#elif !defined(__cpp_noexcept_function_type) || __cpp_noexcept_function_type < 201510L
416#define MDBX_CXX17_NOEXCEPT
417#else
418#define MDBX_CXX17_NOEXCEPT noexcept
419#endif /* MDBX_CXX17_NOEXCEPT */
420
422#if defined(DOXYGEN)
423#define MDBX_CXX01_CONSTEXPR constexpr
424#define MDBX_CXX01_CONSTEXPR_VAR constexpr
425#elif !defined(__cplusplus)
426#define MDBX_CXX01_CONSTEXPR __inline
427#define MDBX_CXX01_CONSTEXPR_VAR const
428#elif !defined(DOXYGEN) && \
429 ((__cplusplus < 201103L && defined(__cpp_constexpr) && __cpp_constexpr < 200704L) || \
430 (defined(__LCC__) && __LCC__ < 124) || \
431 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
432 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4))
433#define MDBX_CXX01_CONSTEXPR inline
434#define MDBX_CXX01_CONSTEXPR_VAR const
435#else
436#define MDBX_CXX01_CONSTEXPR constexpr
437#define MDBX_CXX01_CONSTEXPR_VAR constexpr
438#endif /* MDBX_CXX01_CONSTEXPR */
439
442#if defined(DOXYGEN)
443#define MDBX_CXX11_CONSTEXPR constexpr
444#define MDBX_CXX11_CONSTEXPR_VAR constexpr
445#elif !defined(__cplusplus)
446#define MDBX_CXX11_CONSTEXPR __inline
447#define MDBX_CXX11_CONSTEXPR_VAR const
448#elif !defined(DOXYGEN) && \
449 (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || (defined(__LCC__) && __LCC__ < 124) || \
450 (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && !defined(__LCC__)) || \
451 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 5))
452#define MDBX_CXX11_CONSTEXPR inline
453#define MDBX_CXX11_CONSTEXPR_VAR const
454#else
455#define MDBX_CXX11_CONSTEXPR constexpr
456#define MDBX_CXX11_CONSTEXPR_VAR constexpr
457#endif /* MDBX_CXX11_CONSTEXPR */
458
461#if defined(DOXYGEN)
462#define MDBX_CXX14_CONSTEXPR constexpr
463#define MDBX_CXX14_CONSTEXPR_VAR constexpr
464#elif !defined(__cplusplus)
465#define MDBX_CXX14_CONSTEXPR __inline
466#define MDBX_CXX14_CONSTEXPR_VAR const
467#elif defined(DOXYGEN) || \
468 defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
469 ((defined(_MSC_VER) && _MSC_VER >= 1910) || (defined(__clang__) && __clang_major__ > 4) || \
470 (defined(__GNUC__) && __GNUC__ > 6) || (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
471#define MDBX_CXX14_CONSTEXPR constexpr
472#define MDBX_CXX14_CONSTEXPR_VAR constexpr
473#else
474#define MDBX_CXX14_CONSTEXPR inline
475#define MDBX_CXX14_CONSTEXPR_VAR const
476#endif /* MDBX_CXX14_CONSTEXPR */
477
478#if defined(__noreturn)
479#define MDBX_NORETURN __noreturn
480#elif defined(_Noreturn)
481#define MDBX_NORETURN _Noreturn
482#elif defined(DOXYGEN) || (defined(__cplusplus) && __cplusplus >= 201103L) || \
483 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
484#define MDBX_NORETURN [[noreturn]]
485#elif defined(__GNUC__) || __has_attribute(__noreturn__)
486#define MDBX_NORETURN __attribute__((__noreturn__))
487#elif defined(_MSC_VER) && !defined(__clang__)
488#define MDBX_NORETURN __declspec(noreturn)
489#else
490#define MDBX_NORETURN
491#endif /* MDBX_NORETURN */
492
493#ifndef MDBX_PRINTF_ARGS
494#if defined(__GNUC__) || __has_attribute(__format__) || defined(DOXYGEN)
495#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
496#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
497#else
498#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__printf__, format_index, first_arg)))
499#endif /* MinGW */
500#else
501#define MDBX_PRINTF_ARGS(format_index, first_arg)
502#endif
503#endif /* MDBX_PRINTF_ARGS */
504
505#if defined(DOXYGEN) || \
506 (defined(__cplusplus) && __cplusplus >= 201603L && __has_cpp_attribute(maybe_unused) && \
507 __has_cpp_attribute(maybe_unused) >= 201603L && (!defined(__clang__) || __clang__ > 19)) || \
508 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
509#define MDBX_MAYBE_UNUSED [[maybe_unused]]
510#elif defined(__GNUC__) || __has_attribute(__unused__)
511#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
512#else
513#define MDBX_MAYBE_UNUSED
514#endif /* MDBX_MAYBE_UNUSED */
515
516#if __has_attribute(no_sanitize) || defined(DOXYGEN)
517#define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
518#else
519#define MDBX_NOSANITIZE_ENUM
520#endif /* MDBX_NOSANITIZE_ENUM */
521
522/* Oh, below are some songs and dances since:
523 * - C++ requires explicit definition of the necessary operators.
524 * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
525 * the constexpr feature which is broken in most old compilers;
526 * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
527#if !defined(DEFINE_ENUM_FLAG_OPERATORS) && !defined(DOXYGEN)
528
529#ifdef __cplusplus
530#if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || (defined(__LCC__) && __LCC__ < 124) || \
531 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
532 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4)
533/* The constexpr feature is not available or (may be) broken */
534#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
535#else
536/* C always allows these operators for enums */
537#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
538#endif /* __cpp_constexpr */
539
542#define DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
543 extern "C++" { \
544 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { return ENUM(unsigned(a) | unsigned(b)); } \
545 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, ENUM b) { return a = a | b; } \
546 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { return ENUM(unsigned(a) & unsigned(b)); } \
547 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, unsigned b) { return ENUM(unsigned(a) & b); } \
548 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, ENUM b) { return ENUM(a & unsigned(b)); } \
549 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, ENUM b) { return a = a & b; } \
550 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, unsigned b) { return a = a & b; } \
551 MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
552 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { return ENUM(unsigned(a) ^ unsigned(b)); } \
553 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, ENUM b) { return a = a ^ b; } \
554 }
555#else /* __cplusplus */
556/* nope for C since it always allows these operators for enums */
557#define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
558#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
559#endif /* !__cplusplus */
560
561#elif !defined(CONSTEXPR_ENUM_FLAGS_OPERATIONS)
562
563#ifdef __cplusplus
564/* DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
565#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
566#else
567/* C always allows these operators for enums */
568#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
569#endif
570
571#endif /* DEFINE_ENUM_FLAG_OPERATORS */
572
574
575/*----------------------------------------------------------------------------*/
576
579
580#ifdef __cplusplus
581extern "C" {
582#endif
583
584/* MDBX version 0.14.x, but it is unstable/under-development yet. */
585#define MDBX_VERSION_UNSTABLE
586#define MDBX_VERSION_MAJOR 0
587#define MDBX_VERSION_MINOR 14
588
589#ifndef LIBMDBX_API
590#if defined(LIBMDBX_EXPORTS) || defined(DOXYGEN)
591#define LIBMDBX_API __dll_export
592#elif defined(LIBMDBX_IMPORTS)
593#define LIBMDBX_API __dll_import
594#else
595#define LIBMDBX_API
596#endif
597#endif /* LIBMDBX_API */
598
599#ifdef __cplusplus
600#if defined(__clang__) || __has_attribute(type_visibility) || defined(DOXYGEN)
601#define LIBMDBX_API_TYPE LIBMDBX_API __attribute__((type_visibility("default")))
602#else
603#define LIBMDBX_API_TYPE LIBMDBX_API
604#endif
605#else
606#define LIBMDBX_API_TYPE
607#endif /* LIBMDBX_API_TYPE */
608
609#if defined(LIBMDBX_IMPORTS)
610#define LIBMDBX_VERINFO_API __dll_import
611#else
612#define LIBMDBX_VERINFO_API __dll_export
613#endif /* LIBMDBX_VERINFO_API */
614
617 uint16_t major;
618 uint16_t minor;
619 uint16_t patch;
620 uint16_t tweak;
621 const char *semver_prerelease;
622 struct {
623 const char *datetime;
624 const char *tree;
625 const char *commit;
626 const char *describe;
627 } git;
628 const char *sourcery;
630
635 const char *datetime;
636 const char *target;
637 const char *options;
638 const char *compiler;
639 const char *flags;
640 const char *metadata;
644
645#if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
646/* MDBX internally uses global and thread local storage destructors to
647 * automatically (de)initialization, releasing reader lock table slots
648 * and so on.
649 *
650 * If MDBX built as a DLL this is done out-of-the-box by DllEntry() function,
651 * which called automatically by Windows core with passing corresponding reason
652 * argument.
653 *
654 * Otherwise, if MDBX was built not as a DLL, some black magic
655 * may be required depending of Windows version:
656 *
657 * - Modern Windows versions, including Windows Vista and later, provides
658 * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
659 * or dll file). In this case, MDBX capable of doing all automatically,
660 * therefore you DON'T NEED to call mdbx_module_handler()
661 * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
662 *
663 * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
664 * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
665 * of your DLL or application,
666 * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
667 *
668 * Therefore, building MDBX as a DLL is recommended for all version of Windows.
669 * So, if you doubt, just build MDBX as the separate DLL and don't care about
670 * the MDBX_MANUAL_MODULE_HANDLER. */
671
672#ifndef _WIN32_WINNT
673#error Non-dll build libmdbx requires target Windows version \
674 to be explicitly defined via _WIN32_WINNT for properly \
675 handling thread local storage destructors.
676#endif /* _WIN32_WINNT */
677
678#if _WIN32_WINNT >= 0x0600 /* Windows Vista */
679/* As described above mdbx_module_handler() is NOT needed for Windows Vista
680 * and later. */
681#define MDBX_MANUAL_MODULE_HANDLER 0
682#else
683/* As described above mdbx_module_handler() IS REQUIRED for Windows versions
684 * prior to Windows Vista. */
685#define MDBX_MANUAL_MODULE_HANDLER 1
686void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason, PVOID reserved);
687#endif
688
689#endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
690
691/* OPACITY STRUCTURES *********************************************************/
692
697#ifndef __cplusplus
698typedef struct MDBX_env MDBX_env;
699#else
700struct MDBX_env;
701#endif
702
708#ifndef __cplusplus
709typedef struct MDBX_txn MDBX_txn;
710#else
711struct MDBX_txn;
712#endif
713
721typedef uint32_t MDBX_dbi;
722
727#ifndef __cplusplus
729#else
730struct MDBX_cursor;
731#endif
732
747#ifndef HAVE_STRUCT_IOVEC
748struct iovec {
749 void *iov_base;
750 size_t iov_len;
751};
752#define HAVE_STRUCT_IOVEC
753#endif /* HAVE_STRUCT_IOVEC */
754
755#if defined(__sun) || defined(__SVR4) || defined(__svr4__)
756/* The `iov_len` is signed on Sun/Solaris.
757 * So define custom MDBX_val to avoid a lot of warnings. */
758struct MDBX_val {
759 void *iov_base;
760 size_t iov_len;
761};
762#ifndef __cplusplus
763typedef struct MDBX_val MDBX_val;
764#endif
765#else /* SunOS */
766typedef struct iovec MDBX_val;
767#endif /* ! SunOS */
768
771 MDBX_MAX_DBI = UINT32_C(32765),
772
774 MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
775
778
781};
782
783/* THE FILES *******************************************************************
784 * At the file system level, the environment corresponds to a pair of files. */
785
786#ifndef MDBX_LOCKNAME
789#if !(defined(_WIN32) || defined(_WIN64))
790#define MDBX_LOCKNAME "/mdbx.lck"
791#else
792#define MDBX_LOCKNAME_W L"\\mdbx.lck"
793#define MDBX_LOCKNAME_A "\\mdbx.lck"
794#ifdef UNICODE
795#define MDBX_LOCKNAME MDBX_LOCKNAME_W
796#else
797#define MDBX_LOCKNAME MDBX_LOCKNAME_A
798#endif /* UNICODE */
799#endif /* Windows */
800#endif /* MDBX_LOCKNAME */
801#ifndef MDBX_DATANAME
804#if !(defined(_WIN32) || defined(_WIN64))
805#define MDBX_DATANAME "/mdbx.dat"
806#else
807#define MDBX_DATANAME_W L"\\mdbx.dat"
808#define MDBX_DATANAME_A "\\mdbx.dat"
809#ifdef UNICODE
810#define MDBX_DATANAME MDBX_DATANAME_W
811#else
812#define MDBX_DATANAME MDBX_DATANAME_A
813#endif /* UNICODE */
814#endif /* Windows */
815#endif /* MDBX_DATANAME */
816
817#ifndef MDBX_LOCK_SUFFIX
819#if !(defined(_WIN32) || defined(_WIN64))
820#define MDBX_LOCK_SUFFIX "-lck"
821#else
822#define MDBX_LOCK_SUFFIX_W L"-lck"
823#define MDBX_LOCK_SUFFIX_A "-lck"
824#ifdef UNICODE
825#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_W
826#else
827#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_A
828#endif /* UNICODE */
829#endif /* Windows */
830#endif /* MDBX_LOCK_SUFFIX */
831
832/* DEBUG & LOGGING ************************************************************/
833
837
841typedef enum MDBX_log_level {
846
852
858
864
869
874
879
884
885#ifdef ENABLE_UBSAN
886 MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
887#endif /* ENABLE_UBSAN */
888
892
898typedef enum MDBX_debug_flags {
900
905
909
913
917
920
923
928
929#ifdef ENABLE_UBSAN
930 MDBX_DBG_MAX = ((unsigned)MDBX_LOG_MAX) << 16 | 127 /* avoid UBSAN false-positive trap by a tests */,
931#endif /* ENABLE_UBSAN */
932
936DEFINE_ENUM_FLAG_OPERATORS(MDBX_debug_flags)
937
938
952typedef void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt,
953 va_list args) MDBX_CXX17_NOEXCEPT;
954
956#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
957#define MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt *)(intptr_t)-1)
958
963
964typedef void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg,
965 unsigned length) MDBX_CXX17_NOEXCEPT;
966
968 MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size);
969
980typedef void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function,
981 unsigned line) MDBX_CXX17_NOEXCEPT;
982
993
1003LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize);
1004
1006MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
1007
1010MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line);
1012
1017typedef enum MDBX_env_flags {
1019
1025 MDBX_VALIDATION = UINT32_C(0x00002000),
1026
1043 MDBX_NOSUBDIR = UINT32_C(0x4000),
1044
1061 MDBX_RDONLY = UINT32_C(0x20000),
1062
1091 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1092
1106 MDBX_ACCEDE = UINT32_C(0x40000000),
1107
1137 MDBX_WRITEMAP = UINT32_C(0x80000),
1138
1208 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1209
1211 MDBX_NOTLS MDBX_DEPRECATED_ENUM = MDBX_NOSTICKYTHREADS,
1212
1232 MDBX_NORDAHEAD = UINT32_C(0x800000),
1233
1255 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1256
1268 MDBX_COALESCE MDBX_DEPRECATED_ENUM = UINT32_C(0x2000000),
1269
1292 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1293
1295 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1296
1297 /* SYNC MODES****************************************************************/
1339
1350
1367 MDBX_NOMETASYNC = UINT32_C(0x40000),
1368
1418 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1419
1426
1469
1472DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1473
1474
1478typedef enum MDBX_txn_flags {
1484
1490
1497#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1499#else
1500 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1501#endif
1502
1504 MDBX_TXN_TRY = UINT32_C(0x10000000),
1505
1509
1513
1514 /* Transaction state flags ---------------------------------------------- */
1515
1519 MDBX_TXN_INVALID = INT32_MIN,
1520
1525
1530
1535
1540
1545
1550
1557
1564
1570DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1571
1572
1576typedef enum MDBX_db_flags {
1579
1581 MDBX_REVERSEKEY = UINT32_C(0x02),
1582
1584 MDBX_DUPSORT = UINT32_C(0x04),
1585
1591 MDBX_INTEGERKEY = UINT32_C(0x08),
1592
1595 MDBX_DUPFIXED = UINT32_C(0x10),
1596
1600 MDBX_INTEGERDUP = UINT32_C(0x20),
1601
1603 MDBX_REVERSEDUP = UINT32_C(0x40),
1604
1606 MDBX_CREATE = UINT32_C(0x40000),
1607
1620DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1621
1622
1626typedef enum MDBX_put_flags {
1629
1631 MDBX_NOOVERWRITE = UINT32_C(0x10),
1632
1635 MDBX_NODUPDATA = UINT32_C(0x20),
1636
1641 MDBX_CURRENT = UINT32_C(0x40),
1642
1646 MDBX_ALLDUPS = UINT32_C(0x80),
1647
1650 MDBX_RESERVE = UINT32_C(0x10000),
1651
1654 MDBX_APPEND = UINT32_C(0x20000),
1655
1659 MDBX_APPENDDUP = UINT32_C(0x40000),
1660
1663 MDBX_MULTIPLE = UINT32_C(0x80000)
1665DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1666
1667
1697DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1698
1699
1824
1830typedef enum MDBX_error {
1833
1836
1839
1842
1845
1848
1851
1854
1857 MDBX_PANIC = -30795,
1858
1861
1864
1867
1870
1873
1876
1880
1883
1892
1902
1906
1911
1915
1919
1922
1925
1928 MDBX_BUSY = -30778,
1929
1932
1935
1940
1944
1947
1951
1955
1958
1964
1967
1971
1974 MDBX_OUSTED = -30411,
1975
1978
1979 /* The last of MDBX-added error codes */
1981
1982#if defined(_WIN32) || defined(_WIN64)
1983 MDBX_ENODATA = ERROR_HANDLE_EOF,
1984 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
1985 MDBX_EACCESS = ERROR_ACCESS_DENIED,
1986 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
1987 MDBX_EROFS = ERROR_FILE_READ_ONLY,
1988 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
1989 MDBX_EIO = ERROR_WRITE_FAULT,
1990 MDBX_EPERM = ERROR_INVALID_FUNCTION,
1991 MDBX_EINTR = ERROR_CANCELLED,
1992 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
1993 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
1994 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
1995#else /* Windows */
1996#ifdef ENODATA
1997 MDBX_ENODATA = ENODATA,
1998#else
1999 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2000#endif /* ENODATA */
2001 MDBX_EINVAL = EINVAL,
2003 MDBX_ENOMEM = ENOMEM,
2004 MDBX_EROFS = EROFS,
2005 MDBX_ENOSYS = ENOSYS,
2007 MDBX_EPERM = EPERM,
2008 MDBX_EINTR = EINTR,
2010#if defined(EREMOTEIO) || defined(DOXYGEN)
2012 MDBX_EREMOTE = EREMOTEIO,
2013#else
2014 MDBX_EREMOTE = ENOTBLK,
2015#endif /* EREMOTEIO */
2017#endif /* !Windows */
2018} MDBX_error_t;
2019
2024MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated(void) { return MDBX_UNABLE_EXTEND_MAPSIZE; }
2025#define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
2026
2045LIBMDBX_API const char *mdbx_strerror(int errnum);
2046
2071LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2073
2074#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2079LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2080
2085LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen);
2086#endif /* Bit of Windows' madness */
2087
2103
2408
2419LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value);
2420
2431LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue);
2432
2505LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2506
2507#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2511LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2512#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_openW(env, pathname, flags, mode)
2513#else
2514#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_open(env, pathname, flags, mode)
2515#endif /* Windows */
2516
2535
2556
2557#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2562LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode);
2563#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteW(pathname, mode)
2564#else
2565#define mdbx_env_deleteT(pathname, mode) mdbx_env_delete(pathname, mode)
2566#endif /* Windows */
2567
2621LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags);
2622
2677
2678#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2683LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags);
2684#define mdbx_env_copyT(env, dest, flags) mdbx_env_copyW(env, dest, flags)
2685
2691#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathnameW(txn, dest, path)
2692#else
2693#define mdbx_env_copyT(env, dest, flags) mdbx_env_copy(env, dest, flags)
2694#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathname(txn, dest, path)
2695#endif /* Windows */
2696
2722
2747
2752 uint32_t ms_psize;
2754 uint32_t ms_depth;
2756 uint64_t ms_leaf_pages;
2758 uint64_t ms_entries;
2759 uint64_t ms_mod_txnid;
2760};
2761#ifndef __cplusplus
2763typedef struct MDBX_stat MDBX_stat;
2764#endif
2765
2785LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes);
2786
2790MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes) {
2791 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2792}
2793
2798 struct {
2799 uint64_t lower;
2800 uint64_t upper;
2801 uint64_t current;
2802 uint64_t shrink;
2803 uint64_t grow;
2805 uint64_t mi_mapsize;
2806 uint64_t mi_last_pgno;
2812 uint32_t mi_maxreaders;
2813 uint32_t mi_numreaders;
2816
2825 struct {
2826 struct {
2827 uint64_t x, y;
2828 } current, meta[3];
2830
2847 uint32_t mi_mode;
2848
2854 struct {
2855 uint64_t newly;
2856 uint64_t cow;
2857 uint64_t clone;
2859 uint64_t split;
2860 uint64_t merge;
2861 uint64_t spill;
2862 uint64_t unspill;
2863 uint64_t wops;
2865 uint64_t prefault;
2866 uint64_t mincore;
2867 uint64_t msync;
2868 uint64_t fsync;
2870
2871 /* GUID of the database DXB file. */
2872 struct {
2873 uint64_t x, y;
2875};
2876#ifndef __cplusplus
2878typedef struct MDBX_envinfo MDBX_envinfo;
2879#endif
2880
2901LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes);
2905MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes) {
2906 return mdbx_env_info_ex(env, NULL, info, bytes);
2907}
2908
2945LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2946
2950inline int mdbx_env_sync(MDBX_env * env) { return mdbx_env_sync_ex(env, true, false); }
2951
2955inline int mdbx_env_sync_poll(MDBX_env * env) { return mdbx_env_sync_ex(env, false, true); }
2956
2980inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
2981 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
2982}
2983
2998inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
2999 int rc = MDBX_EINVAL;
3000 if (threshold) {
3001 uint64_t proxy = 0;
3002 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3003#ifdef assert
3004 assert(proxy <= SIZE_MAX);
3005#endif /* assert */
3006 *threshold = (size_t)proxy;
3007 }
3008 return rc;
3009}
3010
3041inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3042 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3043}
3044
3061inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3062 int rc = MDBX_EINVAL;
3063 if (period_seconds_16dot16) {
3064 uint64_t proxy = 0;
3065 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3066#ifdef assert
3067 assert(proxy <= UINT32_MAX);
3068#endif /* assert */
3069 *period_seconds_16dot16 = (unsigned)proxy;
3070 }
3071 return rc;
3072}
3073
3113LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3114
3118inline int mdbx_env_close(MDBX_env * env) { return mdbx_env_close_ex(env, false); }
3119
3120#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3198#endif /* Windows */
3199
3248DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3249
3250
3282 unsigned timeout_seconds_16dot16);
3283
3305
3316LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3317
3331LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3332
3333#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3338LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3339#define mdbx_env_get_pathT(env, dest) mdbx_env_get_pathW(env, dest)
3340#else
3341#define mdbx_env_get_pathT(env, dest) mdbx_env_get_path(env, dest)
3342#endif /* Windows */
3343
3357
3554LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper,
3555 intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize);
3556
3559MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3560 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3561}
3562
3578LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy);
3579
3583
3587
3592
3597
3603
3608
3614
3619
3625 MDBX_db_flags_t flags);
3626
3633
3638
3662inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3663 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3664}
3665
3677inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3678 int rc = MDBX_EINVAL;
3679 if (readers) {
3680 uint64_t proxy = 0;
3681 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3682 *readers = (unsigned)proxy;
3683 }
3684 return rc;
3685}
3686
3708inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3709 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3710}
3711
3722inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3723 int rc = MDBX_EINVAL;
3724 if (dbs) {
3725 uint64_t proxy = 0;
3726 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3727 *dbs = (MDBX_dbi)proxy;
3728 }
3729 return rc;
3730}
3731
3737
3752LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages);
3753
3764
3775
3780
3792
3804
3815
3825
3886 void *context);
3887
3942inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) {
3943 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3944}
3945
3957
3969
3976 uint64_t txn_id;
3977
3983
3987
3990
3994
4002
4009
4016};
4017#ifndef __cplusplus
4019typedef struct MDBX_txn_info MDBX_txn_info;
4020#endif
4021
4035LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt);
4036
4042
4053
4066
4074 uint32_t preparation;
4078 uint32_t audit;
4081 uint32_t write;
4084 uint32_t sync;
4086 uint32_t ending;
4088 uint32_t whole;
4090 uint32_t gc_cputime;
4091
4099 struct {
4102 uint32_t wloops;
4104 uint32_t coalescences;
4107 uint32_t wipes;
4111 uint32_t flushes;
4115 uint32_t kicks;
4116
4119 uint32_t work_counter;
4122 uint32_t work_rtime_monotonic;
4126 uint32_t work_xtime_cpu;
4129 uint32_t work_rsteps;
4132 uint32_t work_xpages;
4135 uint32_t work_majflt;
4136
4139 uint32_t self_counter;
4142 uint32_t self_rtime_monotonic;
4146 uint32_t self_xtime_cpu;
4149 uint32_t self_rsteps;
4152 uint32_t self_xpages;
4155 uint32_t self_majflt;
4156 /* Для разборок с pnl_merge() */
4157 struct {
4158 uint32_t time;
4159 uint64_t volume;
4160 uint32_t calls;
4161 } pnl_merge_work, pnl_merge_self;
4163};
4164#ifndef __cplusplus
4167#endif
4168
4175
4217inline int mdbx_txn_commit(MDBX_txn * txn) { return mdbx_txn_commit_ex(txn, NULL); }
4218
4253
4266
4301
4345LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4346
4388LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4389
4411
4423 uint64_t x, y, z, v;
4424};
4425#ifndef __cplusplus
4427typedef struct MDBX_canary MDBX_canary;
4428#endif
4429
4449
4461
4482typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4483
4573LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi);
4577
4594MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi,
4595 MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4598MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4599 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4600
4616LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4620
4640typedef int(MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4641 const struct MDBX_stat *stat, MDBX_dbi dbi) MDBX_CXX17_NOEXCEPT;
4642
4664
4677
4679
4680MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
4681
4683
4684MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
4685
4686MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
4687 return UINT64_C(0x8000000000000000) + i64;
4688}
4689
4690MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
4691 return UINT32_C(0x80000000) + i32;
4692}
4693
4694
4701
4703
4705
4707
4710
4725LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes);
4726
4742LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask);
4743
4747typedef enum MDBX_dbi_state {
4757DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
4758
4759
4770LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state);
4775inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
4776 unsigned state;
4777 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
4778}
4779
4806
4818LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
4819
4854LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data);
4855
4886LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count);
4887
4917
4999LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags);
5000
5044LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data,
5045 MDBX_put_flags_t flags);
5046
5047typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes);
5048LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data,
5049 MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver,
5050 void *preserver_context);
5051
5077LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data);
5078
5102
5113
5124
5155
5182
5196
5228
5249
5272
5295LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count);
5296
5317inline int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind) {
5318 return mdbx_txn_release_all_cursors_ex(txn, unbind, NULL);
5319}
5320
5346
5352
5358
5370
5392LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival);
5393
5426
5441
5471typedef int(MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) MDBX_CXX17_NOEXCEPT;
5472
5541LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context,
5542 MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg);
5543
5629 MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value,
5630 MDBX_cursor_op turn_op, void *arg);
5631
5673LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit,
5674 MDBX_cursor_op op);
5675
5757
5789
5807LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count);
5808
5831LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes);
5832
5846
5859
5872
5885
5898
5923
5943LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items);
5944
5966 ptrdiff_t *distance_items);
5967
5992LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key,
5993 const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data,
5994 ptrdiff_t *distance_items);
5995
5998#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
5999
6034
6056LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment);
6057
6074 const MDBX_val *b);
6075
6079
6096 const MDBX_val *b);
6097
6101
6127typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid,
6128 uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6129
6142
6152
6165MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent);
6166
6186
6201
6275typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6276 unsigned gap, size_t space, int retry) MDBX_CXX17_NOEXCEPT;
6277
6297
6311
6317
6321LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
6322
6327
6337LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable);
6338
6339#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6344LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta,
6345 bool writeable);
6346#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6347 mdbx_env_open_for_recoveryW(env, pathname, target_mets, writeable)
6348#else
6349#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6350 mdbx_env_open_for_recovery(env, pathname, target_mets, writeable)
6351#endif /* Windows */
6352
6358LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
6359
6391LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes);
6392#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6397LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes);
6398#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfoW(pathname, info, bytes)
6399#else
6400#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfo(pathname, info, bytes)
6401#endif /* Windows */
6402
6426DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
6427
6428
6446
6464
6467typedef struct MDBX_chk_line {
6468 struct MDBX_chk_context *ctx;
6470 char *begin, *end, *out;
6472
6475typedef struct MDBX_chk_issue {
6476 struct MDBX_chk_issue *next;
6477 size_t count;
6478 const char *caption;
6480
6483typedef struct MDBX_chk_scope {
6485 struct MDBX_chk_internal *internal;
6486 const void *object;
6490 union {
6491 void *ptr;
6492 size_t number;
6493 } usr_z, usr_v, usr_o;
6495
6499typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
6500
6506 struct {
6507 size_t begin, end, amount, count;
6509};
6510
6514typedef struct MDBX_chk_table {
6516
6518#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
6520#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
6522#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
6523
6526 int id;
6527
6529 struct {
6530 size_t all, empty, other;
6531 size_t branch, leaf;
6533 } pages;
6534 struct {
6536 struct MDBX_chk_histogram deep;
6547 } histogram;
6549
6571
6587typedef struct MDBX_chk_callbacks {
6589 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt,
6590 va_list args);
6593 void (*issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue,
6594 const char *extra_fmt, va_list extra_args);
6596 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err);
6598
6599 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number,
6600 const MDBX_val *key, const MDBX_val *value);
6601
6604
6608 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
6609 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
6610 void (*print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix);
6612
6643 const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity,
6644 unsigned timeout_seconds_16dot16);
6645
6652
6654
6656
6657#ifdef __cplusplus
6658} /* extern "C" */
6659#endif
6660
6661#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:2805
uint32_t wipes
Количество уничтожений предыдущих надежных/устойчивых точек фиксации при работе в режиме MDBX_UTTERLY...
uint64_t txn_space_dirty
Definition mdbx.h:4015
struct MDBX_envinfo::@012005163333303136244023145022271211024347140371 mi_geo
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4090
const char * describe
uint32_t mi_dxb_pagesize
Definition mdbx.h:2814
uint32_t mi_maxreaders
Definition mdbx.h:2812
uint64_t v
Definition mdbx.h:4423
uint32_t coalescences
Количество итераций слияния записей GC.
uint32_t mi_numreaders
Definition mdbx.h:2813
uint16_t patch
Definition mdbx.h:619
const char * metadata
Definition mdbx.h:640
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2838
uint32_t self_xpages
Количество запросов на выделение последовательностей страниц для самой GC.
uint16_t major
Definition mdbx.h:617
uint64_t txn_reader_lag
Definition mdbx.h:3982
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2811
uint64_t txn_space_leftover
Definition mdbx.h:4008
struct MDBX_envinfo::@366225332126364017271247035205240304242123014254 mi_pgop_stat
uint64_t txn_space_used
Definition mdbx.h:3986
const char * datetime
Definition mdbx.h:635
uint64_t mi_recent_txnid
Definition mdbx.h:2807
uint64_t mi_autosync_threshold
Definition mdbx.h:2834
const char * semver_prerelease
Definition mdbx.h:621
uint32_t wloops
Количество итераций обновления GC, больше 1 если были повторы/перезапуски.
uint64_t ms_branch_pages
Definition mdbx.h:2755
uint64_t ms_entries
Definition mdbx.h:2758
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4076
uint16_t minor
Definition mdbx.h:618
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2844
uint64_t y
Definition mdbx.h:4423
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:4084
uint64_t txn_space_limit_soft
Definition mdbx.h:3989
uint32_t mi_mode
Definition mdbx.h:2847
const char * options
Definition mdbx.h:637
uint64_t txn_id
Definition mdbx.h:3976
const char * sourcery
Definition mdbx.h:628
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2808
uint64_t ms_overflow_pages
Definition mdbx.h:2757
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:4074
uint64_t z
Definition mdbx.h:4423
uint64_t txn_space_limit_hard
Definition mdbx.h:3993
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4088
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:2811
uint32_t ms_psize
Definition mdbx.h:2752
uint32_t kicks
Количество обращений к механизму Handle-Slow-Readers во избежания приращения БД.
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4078
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:4081
uint64_t txn_space_retired
Definition mdbx.h:4001
uint32_t ms_depth
Definition mdbx.h:2754
uint64_t mi_last_pgno
Definition mdbx.h:2806
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:4086
uint64_t ms_mod_txnid
Definition mdbx.h:2759
uint32_t work_rsteps
Количество итераций поиска внутри GC при выделении страниц ради данных пользователя.
const char * datetime
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2809
uint64_t ms_leaf_pages
Definition mdbx.h:2756
uint64_t x
Definition mdbx.h:4423
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2841
uint64_t mi_unsync_volume
Definition mdbx.h:2832
uint32_t mi_sys_pagesize
Definition mdbx.h:2815
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:5047
#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:4422
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4071
Information about the environment.
Definition mdbx.h:2797
Statistics for a table in the environment.
Definition mdbx.h:2751
Information about the transaction.
Definition mdbx.h:3973
libmdbx version information,
Definition mdbx.h:616
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment)
Sequence generation for a table.
LIBMDBX_API int mdbx_get_equal_or_great(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data)
Get equal or great item from a table.
LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg)
Сканирует таблицу с использованием передаваемого предиката, с уменьшением сопутствующих накладных рас...
LIBMDBX_API int mdbx_canary_put(MDBX_txn *txn, const MDBX_canary *canary)
Set integers markers (aka "canary") associated with the environment.
LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary)
Returns fours integers markers (aka "canary") associated with the environment.
MDBX_put_flags_t
Data changing flags.
Definition mdbx.h:1626
LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit, MDBX_cursor_op op)
Retrieve multiple non-dupsort key/value pairs by cursor.
LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count)
Return count values (aka duplicates) for current key.
LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes)
Return count values (aka duplicates) and nested b-tree statistics for current key.
LIBMDBX_API int mdbx_cursor_scan_from(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value, MDBX_cursor_op turn_op, void *arg)
LIBMDBX_API int mdbx_cmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two keys according to a particular table.
int MDBX_cmp_func(const MDBX_val *a, const MDBX_val *b) noexcept
A callback function used to compare two keys in a table.
Definition mdbx.h:4482
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:5471
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store items into a table.
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a table.
LIBMDBX_API int mdbx_dcmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two data items according to a particular table.
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a table.
@ MDBX_MULTIPLE
Definition mdbx.h:1663
@ MDBX_ALLDUPS
Definition mdbx.h:1646
@ MDBX_CURRENT
Definition mdbx.h:1641
@ MDBX_APPENDDUP
Definition mdbx.h:1659
@ MDBX_NODUPDATA
Definition mdbx.h:1635
@ MDBX_APPEND
Definition mdbx.h:1654
@ MDBX_UPSERT
Definition mdbx.h:1628
@ MDBX_RESERVE
Definition mdbx.h:1650
@ MDBX_NOOVERWRITE
Definition mdbx.h:1631
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу.
LIBMDBX_API int mdbx_cursor_open(MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor)
Create a cursor handle for the specified transaction and DBI handle.
int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind)
Unbind or closes all cursors of a given transaction and of all its parent transactions if ones are.
Definition mdbx.h:5317
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:1703
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:1780
@ MDBX_SEEK_AND_GET_MULTIPLE
Definition mdbx.h:1822
@ MDBX_GET_CURRENT
Definition mdbx.h:1718
@ MDBX_GET_BOTH
Definition mdbx.h:1711
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1799
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1715
@ MDBX_SET_KEY
Definition mdbx.h:1758
@ MDBX_FIRST_DUP
Definition mdbx.h:1708
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1798
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1723
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1809
@ MDBX_NEXT_NODUP
Definition mdbx.h:1743
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1806
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1807
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1814
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1766
@ MDBX_SET_RANGE
Definition mdbx.h:1761
@ MDBX_LAST_DUP
Definition mdbx.h:1729
@ MDBX_PREV
Definition mdbx.h:1746
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1816
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1817
@ MDBX_LAST
Definition mdbx.h:1726
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1797
@ MDBX_PREV_DUP
Definition mdbx.h:1749
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1805
@ MDBX_SET
Definition mdbx.h:1755
@ MDBX_NEXT
Definition mdbx.h:1732
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1800
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1813
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1740
@ MDBX_PREV_NODUP
Definition mdbx.h:1752
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1815
@ MDBX_NEXT_DUP
Definition mdbx.h:1735
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1808
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1794
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1801
@ MDBX_FIRST
Definition mdbx.h:1705
LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp)
Open or Create a named table in the environment with using custom comparison functions.
LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp)
Open or Create a named table in the environment with using custom comparison functions.
LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name)
Переименовает таблицу по DBI-дескриптору
LIBMDBX_API int mdbx_dbi_rename2(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name)
Переименовает таблицу по DBI-дескриптору
LIBMDBX_API int mdbx_dbi_close(MDBX_env *env, MDBX_dbi dbi)
Close a table handle. Normally unnecessary.
LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi)
Open or Create a named table in the environment.
LIBMDBX_API int mdbx_dbi_open2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, MDBX_dbi *dbi)
Open or Create a named table in the environment.
uint32_t MDBX_dbi
A handle for an individual table (key-value spaces) in the environment.
Definition mdbx.h:721
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1576
@ MDBX_INTEGERDUP
Definition mdbx.h:1600
@ MDBX_DB_ACCEDE
Definition mdbx.h:1618
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1578
@ MDBX_REVERSEKEY
Definition mdbx.h:1581
@ MDBX_DUPFIXED
Definition mdbx.h:1595
@ MDBX_INTEGERKEY
Definition mdbx.h:1591
@ MDBX_REVERSEDUP
Definition mdbx.h:1603
@ MDBX_CREATE
Definition mdbx.h:1606
@ MDBX_DUPSORT
Definition mdbx.h:1584
LIBMDBX_API const char * mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize)
Dump given MDBX_val to the buffer.
MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt,...) MDBX_PRINTF_ARGS(1
Panics with message and causes abnormal process termination.
void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg, unsigned length) noexcept
Definition mdbx.h:964
void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function, unsigned line) noexcept
A callback function for most MDBX assert() failures, called before printing the message and aborting.
Definition mdbx.h:980
MDBX_log_level_t
Definition mdbx.h:841
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:898
LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func)
Set or reset the assert() callback of the environment.
MDBX_NORETURN LIBMDBX_API void MDBX_NORETURN LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line)
Panics with asserton failed message and causes abnormal process termination.
void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt, va_list args) noexcept
A debug-logger callback function, called before printing the message and aborting.
Definition mdbx.h:952
LIBMDBX_API int mdbx_setup_debug(MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func *logger)
Setup global log-level, debug options and debug logger.
LIBMDBX_API int mdbx_setup_debug_nofmt(MDBX_log_level_t log_level, MDBX_debug_flags_t debug_flags, MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size)
@ MDBX_LOG_EXTRA
Definition mdbx.h:883
@ MDBX_LOG_WARN
Definition mdbx.h:857
@ MDBX_LOG_TRACE
Definition mdbx.h:878
@ MDBX_LOG_DEBUG
Definition mdbx.h:873
@ MDBX_LOG_FATAL
Definition mdbx.h:845
@ MDBX_LOG_ERROR
Definition mdbx.h:851
@ MDBX_LOG_NOTICE
Definition mdbx.h:863
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:890
@ MDBX_LOG_VERBOSE
Definition mdbx.h:868
@ MDBX_DBG_ASSERT
Definition mdbx.h:904
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:927
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:922
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:919
@ MDBX_DBG_NONE
Definition mdbx.h:899
@ MDBX_DBG_DUMP
Definition mdbx.h:916
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:934
@ MDBX_DBG_AUDIT
Definition mdbx.h:908
@ MDBX_DBG_JITTER
Definition mdbx.h:912
LIBMDBX_API int mdbx_env_set_hsr(MDBX_env *env, MDBX_hsr_func *hsr_callback)
Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which ...
LIBMDBX_API const char * mdbx_strerror(int errnum)
Return a string describing a given error code.
int MDBX_hsr_func(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard, unsigned gap, size_t space, int retry) noexcept
A Handle-Slow-Readers callback function to resolve database full/overflow issue due to a reader(s) wh...
Definition mdbx.h:6275
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1830
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:1857
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1844
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1946
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1891
@ MDBX_EACCESS
Definition mdbx.h:2002
@ MDBX_EIO
Definition mdbx.h:2006
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1850
@ MDBX_TXN_FULL
Definition mdbx.h:1875
@ MDBX_DUPLICATED_CLK
Definition mdbx.h:1966
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1860
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1943
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1957
@ MDBX_EREMOTE
Definition mdbx.h:2012
@ MDBX_TOO_LARGE
Definition mdbx.h:1950
@ MDBX_EBADSIGN
Definition mdbx.h:1939
@ MDBX_CURSOR_FULL
Definition mdbx.h:1879
@ MDBX_ENOFILE
Definition mdbx.h:2009
@ MDBX_BAD_TXN
Definition mdbx.h:1910
@ MDBX_ENODATA
Definition mdbx.h:1999
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1924
@ MDBX_CORRUPTED
Definition mdbx.h:1853
@ MDBX_EPERM
Definition mdbx.h:2007
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1954
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1963
@ MDBX_SUCCESS
Definition mdbx.h:1832
@ MDBX_NOTFOUND
Definition mdbx.h:1847
@ MDBX_RESULT_TRUE
Definition mdbx.h:1838
@ MDBX_INVALID
Definition mdbx.h:1863
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1914
@ MDBX_BUSY
Definition mdbx.h:1928
@ MDBX_OUSTED
Definition mdbx.h:1974
@ MDBX_DBS_FULL
Definition mdbx.h:1869
@ MDBX_EINVAL
Definition mdbx.h:2001
@ MDBX_BAD_RSLOT
Definition mdbx.h:1905
@ MDBX_ENOMEM
Definition mdbx.h:2003
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1931
@ MDBX_RESULT_FALSE
Definition mdbx.h:1835
@ MDBX_EINTR
Definition mdbx.h:2008
@ MDBX_READERS_FULL
Definition mdbx.h:1872
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:1980
@ MDBX_BAD_DBI
Definition mdbx.h:1918
@ MDBX_KEYEXIST
Definition mdbx.h:1841
@ MDBX_DANGLING_DBI
Definition mdbx.h:1970
@ MDBX_EDEADLK
Definition mdbx.h:2016
@ MDBX_PAGE_FULL
Definition mdbx.h:1882
@ MDBX_MAP_FULL
Definition mdbx.h:1866
@ MDBX_PROBLEM
Definition mdbx.h:1921
@ MDBX_ENOSYS
Definition mdbx.h:2005
@ MDBX_EMULTIVAL
Definition mdbx.h:1934
@ MDBX_EROFS
Definition mdbx.h:2004
@ MDBX_MVCC_RETARDED
Definition mdbx.h:1977
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1901
LIBMDBX_API MDBX_cmp_func * mdbx_get_datacmp(MDBX_db_flags_t flags)
Returns default internal data's comparator for given table flags.
LIBMDBX_API int mdbx_reader_check(MDBX_env *env, int *dead)
Check for stale entries in the reader lock table.
LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags)
Copy an MDBX environment to the specified path, with options.
LIBMDBX_API int mdbx_txn_copy2pathname(MDBX_txn *txn, const char *dest, MDBX_copy_flags_t flags)
Copy an MDBX environment by given read transaction to the specified path, with options.
MDBX_copy_flags_t
Environment copy flags.
Definition mdbx.h:1670
int mdbx_env_sync(MDBX_env *env)
The shortcut to calling mdbx_env_sync_ex() with the force=true and nonblock=false arguments.
Definition mdbx.h:2950
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:2955
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:2520
LIBMDBX_API int mdbx_env_copy2fd(MDBX_env *env, mdbx_filehandle_t fd, MDBX_copy_flags_t flags)
Copy an environment to the specified file descriptor, with options.
LIBMDBX_API int mdbx_cursor_ignord(MDBX_cursor *cursor)
Служебная функция для использования в утилитах.
LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags)
Copy an MDBX environment to the specified path, with options.
LIBMDBX_API int mdbx_thread_unregister(const MDBX_env *env)
Unregisters the current thread as a reader for the environment.
LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock)
Flush the environment data buffers to disk.
LIBMDBX_API int mdbx_txn_copy2fd(MDBX_txn *txn, mdbx_filehandle_t fd, MDBX_copy_flags_t flags)
Copy an environment by given read transaction to the specified file descriptor, with options.
LIBMDBX_API int mdbx_env_delete(const char *pathname, MDBX_env_delete_mode_t mode)
Delete the environment's files in a proper and multiprocess-safe way.
LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta, bool writeable)
Open an environment instance using specific meta-page for checking and recovery.
LIBMDBX_API int mdbx_txn_copy2pathnameW(MDBX_txn *txn, const wchar_t *dest, MDBX_copy_flags_t flags)
Copy an MDBX environment by given read transaction to the specified path, with options.
@ MDBX_CP_DISPOSE_TXN
Definition mdbx.h:1689
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1671
@ MDBX_CP_COMPACT
Definition mdbx.h:1675
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1694
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1685
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1678
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1681
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2533
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2527
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2530
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:3118
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1017
LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync)
Close the environment and release the memory map.
LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes)
Получает базовую информацию о БД не открывая её.
LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode)
Open an environment instance.
LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes)
Получает базовую информацию о БД не открывая её.
@ MDBX_NORDAHEAD
Definition mdbx.h:1232
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1018
@ MDBX_COALESCE
Definition mdbx.h:1268
@ MDBX_NOMETASYNC
Definition mdbx.h:1367
@ MDBX_LIFORECLAIM
Definition mdbx.h:1292
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1418
@ MDBX_NOTLS
Definition mdbx.h:1211
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1349
@ MDBX_PAGEPERTURB
Definition mdbx.h:1295
@ MDBX_WRITEMAP
Definition mdbx.h:1137
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1208
@ MDBX_EXCLUSIVE
Definition mdbx.h:1091
@ MDBX_NOMEMINIT
Definition mdbx.h:1255
@ MDBX_MAPASYNC
Definition mdbx.h:1425
@ MDBX_ACCEDE
Definition mdbx.h:1106
@ MDBX_NOSUBDIR
Definition mdbx.h:1043
@ MDBX_RDONLY
Definition mdbx.h:1061
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1468
@ MDBX_VALIDATION
Definition mdbx.h:1025
LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items)
Estimates the distance between cursors as a number of elements.
LIBMDBX_API int mdbx_estimate_move(const MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op move_op, ptrdiff_t *distance_items)
Estimates the move distance.
LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key, const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data, ptrdiff_t *distance_items)
Estimates the size of a range as a number of elements.
int mdbx_env_set_mapsize(MDBX_env *env, size_t size)
Definition mdbx.h:3559
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3708
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:3041
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2107
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:2980
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3204
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:3662
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:2212
@ MDBX_opt_subpage_room_threshold
Задаёт в % минимальный объём свободного места на основной странице, при отсутствии которого вложенные...
Definition mdbx.h:2385
@ MDBX_opt_subpage_limit
Задаёт в % максимальный размер вложенных страниц, используемых для размещения небольшого количества м...
Definition mdbx.h:2379
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2208
@ MDBX_opt_prefer_waf_insteadof_balance
Управляет выбором между стремлением к равномерности наполнения страниц, либо уменьшением количества и...
Definition mdbx.h:2364
@ 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:2312
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2116
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2279
@ MDBX_opt_subpage_reserve_prereq
Задаёт в % минимальный объём свободного места на основной странице, при наличии которого,...
Definition mdbx.h:2401
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2139
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2244
@ 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:2267
@ 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:2179
@ 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:2166
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2133
@ MDBX_opt_subpage_reserve_limit
Задаёт в % ограничение резервирования места на вложенных страницах.
Definition mdbx.h:2406
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2228
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2145
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2193
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2307
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2339
@ MDBX_warmup_touchlimit
Definition mdbx.h:3243
@ MDBX_warmup_force
Definition mdbx.h:3213
@ MDBX_warmup_oomsafe
Definition mdbx.h:3220
@ MDBX_warmup_release
Definition mdbx.h:3246
@ MDBX_warmup_lock
Definition mdbx.h:3235
@ MDBX_warmup_default
Definition mdbx.h:3207
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:3677
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:3061
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:4775
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:2905
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:2998
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:3586
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:4747
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:3582
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:6127
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:3722
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:2790
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:4640
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:4749
@ MDBX_DBI_FRESH
Definition mdbx.h:4753
@ MDBX_DBI_STALE
Definition mdbx.h:4751
@ MDBX_DBI_CREAT
Definition mdbx.h:4755
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:4217
LIBMDBX_API int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency)
Commit all the operations of a transaction into the database and collect latency information.
LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted)
Распарковывает ранее припаркованную читающую транзакцию.
MDBX_txn_flags_t
Definition mdbx.h:1478
LIBMDBX_API void * mdbx_txn_get_userctx(const MDBX_txn *txn)
Returns an application information (a context pointer) associated with the transaction.
int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn)
Create a transaction for use with the environment.
Definition mdbx.h:3942
LIBMDBX_API int mdbx_txn_abort(MDBX_txn *txn)
Abandon all the operations of the transaction instead of saving them.
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition mdbx.h:709
LIBMDBX_API int mdbx_txn_reset(MDBX_txn *txn)
Reset a read-only transaction.
LIBMDBX_API int mdbx_txn_renew(MDBX_txn *txn)
Renew a read-only transaction.
LIBMDBX_API MDBX_txn_flags_t mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
@ MDBX_TXN_RDONLY
Definition mdbx.h:1489
@ MDBX_TXN_ERROR
Definition mdbx.h:1529
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1508
@ MDBX_TXN_SPILLS
Definition mdbx.h:1539
@ MDBX_TXN_OUSTED
Definition mdbx.h:1563
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1544
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1498
@ MDBX_TXN_INVALID
Definition mdbx.h:1519
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1568
@ MDBX_TXN_PARKED
Definition mdbx.h:1549
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1512
@ MDBX_TXN_DIRTY
Definition mdbx.h:1534
@ MDBX_TXN_READWRITE
Definition mdbx.h:1483
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1556
@ MDBX_TXN_TRY
Definition mdbx.h:1504
@ MDBX_TXN_FINISHED
Definition mdbx.h:1524
MDBX_chk_severity_t verbosity
Definition mdbx.h:6488
MDBX_txn * txn
Definition mdbx.h:6555
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:6593
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:6610
size_t pad
Definition mdbx.h:6505
void(* print_done)(MDBX_chk_line_t *)
Definition mdbx.h:6607
struct MDBX_chk_internal * internal
Definition mdbx.h:6553
struct MDBX_chk_histogram nested_tree
Histogram of nested trees height, span length for GC.
uint8_t scope_nesting
Definition mdbx.h:6557
char * end
Definition mdbx.h:6470
uint8_t scope_depth
Definition mdbx.h:6469
struct MDBX_chk_histogram key_len
Keys length histogram.
int(* stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t)
Definition mdbx.h:6602
size_t ones
Definition mdbx.h:6505
int(* stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err)
Definition mdbx.h:6603
int(* table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err)
Definition mdbx.h:6596
void(* print_format)(MDBX_chk_line_t *, const char *fmt, va_list args)
Definition mdbx.h:6609
struct MDBX_chk_internal * internal
Definition mdbx.h:6485
char * begin
Definition mdbx.h:6470
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:6589
size_t subtotal_issues
Definition mdbx.h:6489
struct MDBX_chk_histogram deep
Tree deep histogram.
uint8_t severity
Definition mdbx.h:6469
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:6515
void(* scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner)
Definition mdbx.h:6592
struct MDBX_chk_context * ctx
Definition mdbx.h:6468
MDBX_db_flags_t flags
Definition mdbx.h:6525
int(* scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, int err)
Definition mdbx.h:6591
void(* print_flush)(MDBX_chk_line_t *)
Definition mdbx.h:6606
struct MDBX_chk_issue * next
Definition mdbx.h:6476
struct MDBX_chk_histogram large_pages
Histogram of large/overflow pages length.
char * out
Definition mdbx.h:6470
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:6608
const MDBX_chk_table_t *const * tables
const void * object
Definition mdbx.h:6486
size_t count
Definition mdbx.h:6505
const char * caption
Definition mdbx.h:6478
MDBX_chk_stage_t stage
Definition mdbx.h:6487
struct MDBX_chk_histogram multival
Number of multi-values (aka duplicates) histogram.
MDBX_env * env
Definition mdbx.h:6554
uint8_t empty
Definition mdbx.h:6469
size_t amount
Definition mdbx.h:6505
MDBX_chk_scope_t * scope
Definition mdbx.h:6556
MDBX_chk_issue_t * issues
Definition mdbx.h:6484
size_t payload_bytes
Definition mdbx.h:6528
size_t count
Definition mdbx.h:6477
MDBX_val name
Definition mdbx.h:6524
size_t lost_bytes
Definition mdbx.h:6528
bool(* check_break)(MDBX_chk_context_t *ctx)
Definition mdbx.h:6588
void(* table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table)
Definition mdbx.h:6597
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:6599
int id
Definition mdbx.h:6526
LIBMDBX_API int mdbx_env_chk_encount_problem(MDBX_chk_context_t *ctx)
Вспомогательная функция для подсчета проблем детектируемых приложением, в том числе,...
LIBMDBX_API int mdbx_env_chk(MDBX_env *env, const MDBX_chk_callbacks_t *cb, MDBX_chk_context_t *ctx, const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity, unsigned timeout_seconds_16dot16)
Проверяет целостность базы данных.
MDBX_chk_stage_t
Стадии проверки, сообщаемые через обратные вызовы при проверке целостности базы данных.
Definition mdbx.h:6450
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение...
Definition mdbx.h:6499
MDBX_chk_flags_t
Флаги/опции для проверки целостности базы данных.
Definition mdbx.h:6407
MDBX_chk_severity_t
Уровни логирование/детализации информации, поставляемой через обратные вызовы при проверке целостност...
Definition mdbx.h:6431
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:6456
@ MDBX_chk_init
Definition mdbx.h:6452
@ MDBX_chk_finalize
Definition mdbx.h:6462
@ MDBX_chk_space
Definition mdbx.h:6457
@ MDBX_chk_lock
Definition mdbx.h:6453
@ MDBX_chk_none
Definition mdbx.h:6451
@ MDBX_chk_maindb
Definition mdbx.h:6458
@ MDBX_chk_unlock
Definition mdbx.h:6461
@ MDBX_chk_meta
Definition mdbx.h:6454
@ MDBX_chk_conclude
Definition mdbx.h:6460
@ MDBX_chk_tree
Definition mdbx.h:6455
@ MDBX_chk_tables
Definition mdbx.h:6459
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:6416
@ MDBX_CHK_READWRITE
Definition mdbx.h:6413
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:6409
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:6419
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:6424
@ MDBX_chk_processing
Definition mdbx.h:6440
@ MDBX_chk_result
Definition mdbx.h:6438
@ MDBX_chk_details
Definition mdbx.h:6443
@ MDBX_chk_extra
Definition mdbx.h:6444
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:6432
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:6433
@ MDBX_chk_notice
Definition mdbx.h:6437
@ MDBX_chk_resolution
Definition mdbx.h:6439
@ MDBX_chk_warning
Definition mdbx.h:6436
@ MDBX_chk_fatal
Definition mdbx.h:6434
@ MDBX_chk_info
Definition mdbx.h:6441
@ MDBX_chk_error
Definition mdbx.h:6435
@ MDBX_chk_verbose
Definition mdbx.h:6442
Набор функций обратного вызова используемых при проверке целостности базы данных.
Definition mdbx.h:6587
Контекст проверки целостности базы данных.
Definition mdbx.h:6552
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД.
Definition mdbx.h:6504
Проблема обнаруженная при проверке целостности базы данных.
Definition mdbx.h:6475
Виртуальная строка отчета, формируемого при проверке целостности базы данных.
Definition mdbx.h:6467
Иерархический контекст при проверке целостности базы данных.
Definition mdbx.h:6483
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных.
Definition mdbx.h:6514
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:4686
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:4690
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)