libmdbx 0.14.1.215 (2026-01-01T01:10:47+03:00)
One of the fastest compact embeddable key-value ACID storage engine without WAL.
Loading...
Searching...
No Matches
mdbx.h
Go to the documentation of this file.
1
34
35#pragma once
36#ifndef LIBMDBX_H
37#define LIBMDBX_H
38
39#if defined(__riscv) || defined(__riscv__) || defined(__RISCV) || defined(__RISCV__)
40#warning "The RISC-V architecture is intentionally insecure by design. \
41 Please delete this admonition at your own risk, \
42 if you make such decision informed and consciously. \
43 Refer to https://clck.ru/32d9xH for more information."
44#endif /* RISC-V */
45
46#ifdef _MSC_VER
47#pragma warning(push, 1)
48#pragma warning(disable : 4548) /* expression before comma has no effect; \
49 expected expression with side - effect */
50#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
51 * semantics are not enabled. Specify /EHsc */
52#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
53 * mode specified; termination on exception is \
54 * not guaranteed. Specify /EHsc */
55#endif /* _MSC_VER (warnings) */
56
57/* *INDENT-OFF* */
58/* clang-format off */
141/* *INDENT-ON* */
142/* clang-format on */
143
144#include <stdarg.h>
145#include <stddef.h>
146#include <stdint.h>
147#if !defined(NDEBUG) && !defined(assert)
148#include <assert.h>
149#endif /* NDEBUG */
150
151#if defined(_WIN32) || defined(_WIN64)
152#include <windows.h>
153#include <winnt.h>
154#ifndef __mode_t_defined
155typedef unsigned short mdbx_mode_t;
156#else
157typedef mode_t mdbx_mode_t;
158#endif /* __mode_t_defined */
159typedef HANDLE mdbx_filehandle_t;
160typedef DWORD mdbx_pid_t;
161typedef DWORD mdbx_tid_t;
162#else /* Windows */
163#include <errno.h> /* for error codes */
164#include <pthread.h> /* for pthread_t */
165#include <sys/types.h> /* for pid_t */
166#include <sys/uio.h> /* for struct iovec */
167#define HAVE_STRUCT_IOVEC 1
169typedef pid_t mdbx_pid_t;
170typedef pthread_t mdbx_tid_t;
171typedef mode_t mdbx_mode_t;
172#endif /* !Windows */
173
174#ifdef _MSC_VER
175#pragma warning(pop)
176#endif
177
182
183/*----------------------------------------------------------------------------*/
184
185#ifndef __has_attribute
186#define __has_attribute(x) (0)
187#endif /* __has_attribute */
188
189#ifndef __has_c_attribute
190#define __has_c_attribute(x) (0)
191#define __has_c_attribute_qualified(x) 0
192#elif !defined(__STDC_VERSION__) || __STDC_VERSION__ < 202311L
193#define __has_c_attribute_qualified(x) 0
194#elif defined(_MSC_VER)
195/* MSVC don't support `namespace::attr` syntax */
196#define __has_c_attribute_qualified(x) 0
197#else
198#define __has_c_attribute_qualified(x) __has_c_attribute(x)
199#endif /* __has_c_attribute */
200
201#ifndef __has_cpp_attribute
202#define __has_cpp_attribute(x) 0
203#define __has_cpp_attribute_qualified(x) 0
204#elif defined(_MSC_VER) || (__clang__ && __clang__ < 14)
205/* MSVC don't support `namespace::attr` syntax */
206#define __has_cpp_attribute_qualified(x) 0
207#else
208#define __has_cpp_attribute_qualified(x) __has_cpp_attribute(x)
209#endif /* __has_cpp_attribute */
210
211#ifndef __has_C23_or_CXX_attribute
212#if defined(__cplusplus)
213#define __has_C23_or_CXX_attribute(x) __has_cpp_attribute_qualified(x)
214#else
215#define __has_C23_or_CXX_attribute(x) __has_c_attribute_qualified(x)
216#endif
217#endif /* __has_C23_or_CXX_attribute */
218
219#ifndef __has_feature
220#define __has_feature(x) (0)
221#define __has_exceptions_disabled (0)
222#elif !defined(__has_exceptions_disabled)
223#define __has_exceptions_disabled (__has_feature(cxx_noexcept) && !__has_feature(cxx_exceptions))
224#endif /* __has_feature */
225
226#ifndef __has_extension
227#define __has_extension(x) __has_feature(x)
228#endif /* __has_extension */
229
230#ifndef __has_builtin
231#define __has_builtin(x) (0)
232#endif /* __has_builtin */
233
240#if defined(DOXYGEN)
241#define MDBX_PURE_FUNCTION [[gnu::pure]]
242#elif __has_C23_or_CXX_attribute(gnu::pure)
243#define MDBX_PURE_FUNCTION [[gnu::pure]]
244#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
245 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
246 __has_exceptions_disabled)
247#define MDBX_PURE_FUNCTION __attribute__((__pure__))
248#else
249#define MDBX_PURE_FUNCTION
250#endif /* MDBX_PURE_FUNCTION */
251
255#if defined(DOXYGEN)
256#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
257#elif __has_C23_or_CXX_attribute(gnu::pure)
258#if __has_C23_or_CXX_attribute(gnu::nothrow)
259#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
260#else
261#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
262#endif
263#elif defined(__GNUC__) || (__has_attribute(__pure__) && __has_attribute(__nothrow__))
264#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
265#elif __has_cpp_attribute(pure)
266#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
267#else
268#define MDBX_NOTHROW_PURE_FUNCTION
269#endif /* MDBX_NOTHROW_PURE_FUNCTION */
270
281#if defined(DOXYGEN)
282#define MDBX_CONST_FUNCTION [[gnu::const]]
283#elif __has_C23_or_CXX_attribute(gnu::const)
284#define MDBX_CONST_FUNCTION [[gnu::const]]
285#elif (defined(__GNUC__) || __has_attribute(__const__)) && \
286 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ || !defined(__cplusplus) || \
287 __has_exceptions_disabled)
288#define MDBX_CONST_FUNCTION __attribute__((__const__))
289#else
290#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
291#endif /* MDBX_CONST_FUNCTION */
292
296#if defined(DOXYGEN)
297#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
298#elif __has_C23_or_CXX_attribute(gnu::const)
299#if __has_C23_or_CXX_attribute(gnu::nothrow)
300#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
301#else
302#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const]]
303#endif
304#elif defined(__GNUC__) || (__has_attribute(__const__) && __has_attribute(__nothrow__))
305#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
306#elif __has_cpp_attribute_qualified(const)
307#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
308#else
309#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
310#endif /* MDBX_NOTHROW_CONST_FUNCTION */
311
315#ifndef MDBX_DEPRECATED
316#ifdef __deprecated
317#define MDBX_DEPRECATED __deprecated
318#elif defined(DOXYGEN) || ((!defined(__GNUC__) || (defined(__clang__) && __clang__ > 19) || __GNUC__ > 5) && \
319 ((defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
320 __has_cpp_attribute(deprecated) >= 201309L) || \
321 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202304L)))
322#define MDBX_DEPRECATED [[deprecated]]
323#elif (defined(__GNUC__) && __GNUC__ > 5) || \
324 (__has_attribute(__deprecated__) && (!defined(__GNUC__) || defined(__clang__) || __GNUC__ > 5))
325#define MDBX_DEPRECATED __attribute__((__deprecated__))
326#elif defined(_MSC_VER)
327#define MDBX_DEPRECATED __declspec(deprecated)
328#else
329#define MDBX_DEPRECATED
330#endif
331#endif /* MDBX_DEPRECATED */
332
333#ifndef MDBX_DEPRECATED_ENUM
334#ifdef __deprecated_enum
335#define MDBX_DEPRECATED_ENUM __deprecated_enum
336#elif defined(DOXYGEN) || \
337 (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201403L && __has_cpp_attribute(deprecated) && \
338 __has_cpp_attribute(deprecated) >= 201309L))
339#define MDBX_DEPRECATED_ENUM MDBX_DEPRECATED
340#else
341#define MDBX_DEPRECATED_ENUM /* avoid madness MSVC */
342#endif
343#endif /* MDBX_DEPRECATED_ENUM */
344
345#ifndef __dll_export
346#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
347 defined(__MINGW64__)
348#if defined(__GNUC__) || __has_attribute(__dllexport__)
349#define __dll_export __attribute__((__dllexport__))
350#elif defined(_MSC_VER)
351#define __dll_export __declspec(dllexport)
352#else
353#define __dll_export
354#endif
355#elif defined(__GNUC__) || __has_attribute(__visibility__)
356#define __dll_export __attribute__((__visibility__("default")))
357#else
358#define __dll_export
359#endif
360#endif /* __dll_export */
361
362#ifndef __dll_import
363#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(__MINGW__) || defined(__MINGW32__) || \
364 defined(__MINGW64__)
365#if defined(__GNUC__) || __has_attribute(__dllimport__)
366#define __dll_import __attribute__((__dllimport__))
367#elif defined(_MSC_VER)
368#define __dll_import __declspec(dllimport)
369#else
370#define __dll_import
371#endif
372#else
373#define __dll_import
374#endif
375#endif /* __dll_import */
376
381#if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
382#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
383 /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
384 /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
385#else
386#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
387#endif /* LIBMDBX_INLINE_API */
388
390#ifndef MDBX_STRINGIFY
391#define MDBX_STRINGIFY_HELPER(x) #x
392#define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
393#endif /* MDBX_STRINGIFY */
394
395/*----------------------------------------------------------------------------*/
396
397#ifndef __cplusplus
398#ifndef bool
399#define bool _Bool
400#endif
401#ifndef true
402#define true (1)
403#endif
404#ifndef false
405#define false (0)
406#endif
407#endif /* bool without __cplusplus */
408
410#if defined(DOXYGEN)
411#define MDBX_CXX17_NOEXCEPT noexcept
412#elif !defined(__cpp_noexcept_function_type) || __cpp_noexcept_function_type < 201510L
413#define MDBX_CXX17_NOEXCEPT
414#else
415#define MDBX_CXX17_NOEXCEPT noexcept
416#endif /* MDBX_CXX17_NOEXCEPT */
417
419#if defined(DOXYGEN)
420#define MDBX_CXX01_CONSTEXPR constexpr
421#define MDBX_CXX01_CONSTEXPR_VAR constexpr
422#elif !defined(__cplusplus)
423#define MDBX_CXX01_CONSTEXPR __inline
424#define MDBX_CXX01_CONSTEXPR_VAR const
425#elif !defined(DOXYGEN) && \
426 ((__cplusplus < 201103L && defined(__cpp_constexpr) && __cpp_constexpr < 200704L) || \
427 (defined(__LCC__) && __LCC__ < 124) || \
428 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
429 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4))
430#define MDBX_CXX01_CONSTEXPR inline
431#define MDBX_CXX01_CONSTEXPR_VAR const
432#else
433#define MDBX_CXX01_CONSTEXPR constexpr
434#define MDBX_CXX01_CONSTEXPR_VAR constexpr
435#endif /* MDBX_CXX01_CONSTEXPR */
436
439#if defined(DOXYGEN)
440#define MDBX_CXX11_CONSTEXPR constexpr
441#define MDBX_CXX11_CONSTEXPR_VAR constexpr
442#elif !defined(__cplusplus)
443#define MDBX_CXX11_CONSTEXPR __inline
444#define MDBX_CXX11_CONSTEXPR_VAR const
445#elif !defined(DOXYGEN) && \
446 (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || (defined(__LCC__) && __LCC__ < 124) || \
447 (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && !defined(__LCC__)) || \
448 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 5))
449#define MDBX_CXX11_CONSTEXPR inline
450#define MDBX_CXX11_CONSTEXPR_VAR const
451#else
452#define MDBX_CXX11_CONSTEXPR constexpr
453#define MDBX_CXX11_CONSTEXPR_VAR constexpr
454#endif /* MDBX_CXX11_CONSTEXPR */
455
458#if defined(DOXYGEN)
459#define MDBX_CXX14_CONSTEXPR constexpr
460#define MDBX_CXX14_CONSTEXPR_VAR constexpr
461#elif !defined(__cplusplus)
462#define MDBX_CXX14_CONSTEXPR __inline
463#define MDBX_CXX14_CONSTEXPR_VAR const
464#elif defined(DOXYGEN) || \
465 defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
466 ((defined(_MSC_VER) && _MSC_VER >= 1910) || (defined(__clang__) && __clang_major__ > 4) || \
467 (defined(__GNUC__) && __GNUC__ > 6) || (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
468#define MDBX_CXX14_CONSTEXPR constexpr
469#define MDBX_CXX14_CONSTEXPR_VAR constexpr
470#else
471#define MDBX_CXX14_CONSTEXPR inline
472#define MDBX_CXX14_CONSTEXPR_VAR const
473#endif /* MDBX_CXX14_CONSTEXPR */
474
475#if defined(__noreturn)
476#define MDBX_NORETURN __noreturn
477#elif defined(_Noreturn)
478#define MDBX_NORETURN _Noreturn
479#elif defined(DOXYGEN) || (defined(__cplusplus) && __cplusplus >= 201103L) || \
480 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
481#define MDBX_NORETURN [[noreturn]]
482#elif defined(__GNUC__) || __has_attribute(__noreturn__)
483#define MDBX_NORETURN __attribute__((__noreturn__))
484#elif defined(_MSC_VER) && !defined(__clang__)
485#define MDBX_NORETURN __declspec(noreturn)
486#else
487#define MDBX_NORETURN
488#endif /* MDBX_NORETURN */
489
490#ifndef MDBX_PRINTF_ARGS
491#if defined(__GNUC__) || __has_attribute(__format__) || defined(DOXYGEN)
492#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
493#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
494#else
495#define MDBX_PRINTF_ARGS(format_index, first_arg) __attribute__((__format__(__printf__, format_index, first_arg)))
496#endif /* MinGW */
497#else
498#define MDBX_PRINTF_ARGS(format_index, first_arg)
499#endif
500#endif /* MDBX_PRINTF_ARGS */
501
502#if defined(DOXYGEN) || \
503 (defined(__cplusplus) && __cplusplus >= 201603L && __has_cpp_attribute(maybe_unused) && \
504 __has_cpp_attribute(maybe_unused) >= 201603L && (!defined(__clang__) || __clang__ > 19)) || \
505 (!defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ > 202005L)
506#define MDBX_MAYBE_UNUSED [[maybe_unused]]
507#elif defined(__GNUC__) || __has_attribute(__unused__)
508#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
509#else
510#define MDBX_MAYBE_UNUSED
511#endif /* MDBX_MAYBE_UNUSED */
512
513#if __has_attribute(no_sanitize) || defined(DOXYGEN)
514#define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
515#else
516#define MDBX_NOSANITIZE_ENUM
517#endif /* MDBX_NOSANITIZE_ENUM */
518
519/* Oh, below are some songs and dances since:
520 * - C++ requires explicit definition of the necessary operators.
521 * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
522 * the constexpr feature which is broken in most old compilers;
523 * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
524#if !defined(DEFINE_ENUM_FLAG_OPERATORS) && !defined(DOXYGEN)
525
526#ifdef __cplusplus
527#if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || (defined(__LCC__) && __LCC__ < 124) || \
528 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && !defined(__clang__) && !defined(__LCC__)) || \
529 (defined(_MSC_VER) && _MSC_VER < 1910) || (defined(__clang__) && __clang_major__ < 4)
530/* The constexpr feature is not available or (may be) broken */
531#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
532#else
533/* C always allows these operators for enums */
534#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
535#endif /* __cpp_constexpr */
536
539#define DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
540 extern "C++" { \
541 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { return ENUM(unsigned(a) | unsigned(b)); } \
542 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, ENUM b) { return a = a | b; } \
543 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { return ENUM(unsigned(a) & unsigned(b)); } \
544 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, unsigned b) { return ENUM(unsigned(a) & b); } \
545 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, ENUM b) { return ENUM(a & unsigned(b)); } \
546 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, ENUM b) { return a = a & b; } \
547 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, unsigned b) { return a = a & b; } \
548 MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
549 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { return ENUM(unsigned(a) ^ unsigned(b)); } \
550 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, ENUM b) { return a = a ^ b; } \
551 }
552#else /* __cplusplus */
553/* nope for C since it always allows these operators for enums */
554#define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
555#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
556#endif /* !__cplusplus */
557
558#elif !defined(CONSTEXPR_ENUM_FLAGS_OPERATIONS)
559
560#ifdef __cplusplus
561/* DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
562#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
563#else
564/* C always allows these operators for enums */
565#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
566#endif
567
568#endif /* DEFINE_ENUM_FLAG_OPERATORS */
569
571
572/*----------------------------------------------------------------------------*/
573
576
577#ifdef __cplusplus
578extern "C" {
579#endif
580
581/* MDBX version 0.14.x, but it is unstable/under-development yet. */
582#define MDBX_VERSION_UNSTABLE
583#define MDBX_VERSION_MAJOR 0
584#define MDBX_VERSION_MINOR 14
585
586#ifndef LIBMDBX_API
587#if defined(LIBMDBX_EXPORTS) || defined(DOXYGEN)
588#define LIBMDBX_API __dll_export
589#elif defined(LIBMDBX_IMPORTS)
590#define LIBMDBX_API __dll_import
591#else
592#define LIBMDBX_API
593#endif
594#endif /* LIBMDBX_API */
595
596#ifdef __cplusplus
597#if defined(__clang__) || __has_attribute(type_visibility) || defined(DOXYGEN)
598#define LIBMDBX_API_TYPE LIBMDBX_API __attribute__((type_visibility("default")))
599#else
600#define LIBMDBX_API_TYPE LIBMDBX_API
601#endif
602#else
603#define LIBMDBX_API_TYPE
604#endif /* LIBMDBX_API_TYPE */
605
606#if defined(LIBMDBX_IMPORTS)
607#define LIBMDBX_VERINFO_API __dll_import
608#else
609#define LIBMDBX_VERINFO_API __dll_export
610#endif /* LIBMDBX_VERINFO_API */
611
614 uint16_t major;
615 uint16_t minor;
616 uint16_t patch;
617 uint16_t tweak;
618 const char *semver_prerelease;
619 struct {
620 const char *datetime;
621 const char *tree;
622 const char *commit;
623 const char *describe;
624 } git;
625 const char *sourcery;
627
632 const char *datetime;
633 const char *target;
634 const char *options;
635 const char *compiler;
636 const char *flags;
637 const char *metadata;
641
642#if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
643/* MDBX internally uses global and thread local storage destructors to
644 * automatically (de)initialization, releasing reader lock table slots
645 * and so on.
646 *
647 * If MDBX built as a DLL this is done out-of-the-box by DllEntry() function,
648 * which called automatically by Windows core with passing corresponding reason
649 * argument.
650 *
651 * Otherwise, if MDBX was built not as a DLL, some black magic
652 * may be required depending of Windows version:
653 *
654 * - Modern Windows versions, including Windows Vista and later, provides
655 * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
656 * or dll file). In this case, MDBX capable of doing all automatically,
657 * therefore you DON'T NEED to call mdbx_module_handler()
658 * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
659 *
660 * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
661 * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
662 * of your DLL or application,
663 * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
664 *
665 * Therefore, building MDBX as a DLL is recommended for all version of Windows.
666 * So, if you doubt, just build MDBX as the separate DLL and don't care about
667 * the MDBX_MANUAL_MODULE_HANDLER. */
668
669#ifndef _WIN32_WINNT
670#error Non-dll build libmdbx requires target Windows version \
671 to be explicitly defined via _WIN32_WINNT for properly \
672 handling thread local storage destructors.
673#endif /* _WIN32_WINNT */
674
675#if _WIN32_WINNT >= 0x0600 /* Windows Vista */
676/* As described above mdbx_module_handler() is NOT needed for Windows Vista
677 * and later. */
678#define MDBX_MANUAL_MODULE_HANDLER 0
679#else
680/* As described above mdbx_module_handler() IS REQUIRED for Windows versions
681 * prior to Windows Vista. */
682#define MDBX_MANUAL_MODULE_HANDLER 1
683void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason, PVOID reserved);
684#endif
685
686#endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
687
688/* OPACITY STRUCTURES *********************************************************/
689
694#ifndef __cplusplus
695typedef struct MDBX_env MDBX_env;
696#else
697struct MDBX_env;
698#endif
699
705#ifndef __cplusplus
706typedef struct MDBX_txn MDBX_txn;
707#else
708struct MDBX_txn;
709#endif
710
718typedef uint32_t MDBX_dbi;
719
724#ifndef __cplusplus
726#else
727struct MDBX_cursor;
728#endif
729
744#ifndef HAVE_STRUCT_IOVEC
745struct iovec {
746 void *iov_base;
747 size_t iov_len;
748};
749#define HAVE_STRUCT_IOVEC
750#endif /* HAVE_STRUCT_IOVEC */
751
752#if defined(__sun) || defined(__SVR4) || defined(__svr4__)
753/* The `iov_len` is signed on Sun/Solaris.
754 * So define custom MDBX_val to avoid a lot of warnings. */
755struct MDBX_val {
756 void *iov_base;
757 size_t iov_len;
758};
759#ifndef __cplusplus
760typedef struct MDBX_val MDBX_val;
761#endif
762#else /* SunOS */
763typedef struct iovec MDBX_val;
764#endif /* ! SunOS */
765
768 MDBX_MAX_DBI = UINT32_C(32765),
769
771 MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
772
775
778};
779
780/* THE FILES *******************************************************************
781 * At the file system level, the environment corresponds to a pair of files. */
782
783#ifndef MDBX_LOCKNAME
786#if !(defined(_WIN32) || defined(_WIN64))
787#define MDBX_LOCKNAME "/mdbx.lck"
788#else
789#define MDBX_LOCKNAME_W L"\\mdbx.lck"
790#define MDBX_LOCKNAME_A "\\mdbx.lck"
791#ifdef UNICODE
792#define MDBX_LOCKNAME MDBX_LOCKNAME_W
793#else
794#define MDBX_LOCKNAME MDBX_LOCKNAME_A
795#endif /* UNICODE */
796#endif /* Windows */
797#endif /* MDBX_LOCKNAME */
798#ifndef MDBX_DATANAME
801#if !(defined(_WIN32) || defined(_WIN64))
802#define MDBX_DATANAME "/mdbx.dat"
803#else
804#define MDBX_DATANAME_W L"\\mdbx.dat"
805#define MDBX_DATANAME_A "\\mdbx.dat"
806#ifdef UNICODE
807#define MDBX_DATANAME MDBX_DATANAME_W
808#else
809#define MDBX_DATANAME MDBX_DATANAME_A
810#endif /* UNICODE */
811#endif /* Windows */
812#endif /* MDBX_DATANAME */
813
814#ifndef MDBX_LOCK_SUFFIX
816#if !(defined(_WIN32) || defined(_WIN64))
817#define MDBX_LOCK_SUFFIX "-lck"
818#else
819#define MDBX_LOCK_SUFFIX_W L"-lck"
820#define MDBX_LOCK_SUFFIX_A "-lck"
821#ifdef UNICODE
822#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_W
823#else
824#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_A
825#endif /* UNICODE */
826#endif /* Windows */
827#endif /* MDBX_LOCK_SUFFIX */
828
829/* DEBUG & LOGGING ************************************************************/
830
834
840typedef enum MDBX_log_level {
845
851
857
863
868
873
878
883
884#ifdef ENABLE_UBSAN
885 MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
886#endif /* ENABLE_UBSAN */
887
891
899typedef enum MDBX_debug_flags {
901
906
910
914
918
921
924
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
965
966typedef void MDBX_debug_func_nofmt(MDBX_log_level_t loglevel, const char *function, int line, const char *msg,
967 unsigned length) MDBX_CXX17_NOEXCEPT;
968
970 MDBX_debug_func_nofmt *logger, char *logger_buffer, size_t logger_buffer_size);
971
982typedef void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function,
983 unsigned line) MDBX_CXX17_NOEXCEPT;
984
995
1005LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize);
1006
1008MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
1009
1012#if !((defined(_WIN32) || defined(_WIN64)) && !MDBX_WITHOUT_MSVC_CRT)
1014#endif /* MDBX_WITHOUT_MSVC_CRT */
1015LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func, unsigned line);
1017
1022typedef enum MDBX_env_flags {
1024
1030 MDBX_VALIDATION = UINT32_C(0x00002000),
1031
1048 MDBX_NOSUBDIR = UINT32_C(0x4000),
1049
1066 MDBX_RDONLY = UINT32_C(0x20000),
1067
1096 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1097
1111 MDBX_ACCEDE = UINT32_C(0x40000000),
1112
1142 MDBX_WRITEMAP = UINT32_C(0x80000),
1143
1213 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1214
1216 MDBX_NOTLS MDBX_DEPRECATED_ENUM = MDBX_NOSTICKYTHREADS,
1217
1237 MDBX_NORDAHEAD = UINT32_C(0x800000),
1238
1260 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1261
1273 MDBX_COALESCE MDBX_DEPRECATED_ENUM = UINT32_C(0x2000000),
1274
1297 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1298
1300 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1301
1302 /* SYNC MODES****************************************************************/
1344
1355
1372 MDBX_NOMETASYNC = UINT32_C(0x40000),
1373
1423 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1424
1431
1474
1477DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1478
1479
1483typedef enum MDBX_txn_flags {
1489
1495
1502#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1504#else
1505 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1506#endif
1507
1509 MDBX_TXN_TRY = UINT32_C(0x10000000),
1510
1514
1518
1519 /* Transaction state flags ---------------------------------------------- */
1520
1524 MDBX_TXN_INVALID = INT32_MIN,
1525
1530
1535
1540
1545
1550
1555
1562
1569
1575DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1576
1577
1581typedef enum MDBX_db_flags {
1584
1586 MDBX_REVERSEKEY = UINT32_C(0x02),
1587
1589 MDBX_DUPSORT = UINT32_C(0x04),
1590
1596 MDBX_INTEGERKEY = UINT32_C(0x08),
1597
1600 MDBX_DUPFIXED = UINT32_C(0x10),
1601
1605 MDBX_INTEGERDUP = UINT32_C(0x20),
1606
1608 MDBX_REVERSEDUP = UINT32_C(0x40),
1609
1611 MDBX_CREATE = UINT32_C(0x40000),
1612
1625DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1626
1627
1631typedef enum MDBX_put_flags {
1634
1636 MDBX_NOOVERWRITE = UINT32_C(0x10),
1637
1640 MDBX_NODUPDATA = UINT32_C(0x20),
1641
1646 MDBX_CURRENT = UINT32_C(0x40),
1647
1651 MDBX_ALLDUPS = UINT32_C(0x80),
1652
1655 MDBX_RESERVE = UINT32_C(0x10000),
1656
1659 MDBX_APPEND = UINT32_C(0x20000),
1660
1664 MDBX_APPENDDUP = UINT32_C(0x40000),
1665
1668 MDBX_MULTIPLE = UINT32_C(0x80000)
1670DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1671
1672
1706DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1707
1708
1833
1839typedef enum MDBX_error {
1842
1845
1848
1851
1854
1857
1860
1863
1866 MDBX_PANIC = -30795,
1867
1870
1873
1876
1879
1882
1885
1889
1892
1901
1911
1914
1919
1923
1927
1930
1933
1936 MDBX_BUSY = -30778,
1937
1940
1943
1948
1952
1955
1959
1963
1966
1972
1975
1979
1982 MDBX_OUSTED = -30411,
1983
1986
1987 /* The last of MDBX-added error codes */
1989
1990#if defined(_WIN32) || defined(_WIN64)
1991 MDBX_ENODATA = ERROR_HANDLE_EOF,
1992 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
1993 MDBX_EACCESS = ERROR_ACCESS_DENIED,
1994 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
1995 MDBX_EROFS = ERROR_FILE_READ_ONLY,
1996 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
1997 MDBX_EIO = ERROR_WRITE_FAULT,
1998 MDBX_EPERM = ERROR_INVALID_FUNCTION,
1999 MDBX_EINTR = ERROR_CANCELLED,
2000 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
2001 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
2002 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
2003#else /* Windows */
2004#if defined(ENODATA) || defined(DOXYGEN)
2005 MDBX_ENODATA = ENODATA,
2006#else
2007 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2008#endif /* ENODATA */
2009 MDBX_EINVAL = EINVAL,
2011 MDBX_ENOMEM = ENOMEM,
2012 MDBX_EROFS = EROFS,
2013#if defined(ENOTSUP) || defined(DOXYGEN)
2014 MDBX_ENOSYS = ENOTSUP,
2015#else
2016 MDBX_ENOSYS = ENOSYS,
2017#endif /* ENOTSUP */
2019 MDBX_EPERM = EPERM,
2020 MDBX_EINTR = EINTR,
2022#if defined(EREMOTEIO) || defined(DOXYGEN)
2024 MDBX_EREMOTE = EREMOTEIO,
2025#else
2026 MDBX_EREMOTE = ENOTBLK,
2027#endif /* EREMOTEIO */
2029#endif /* !Windows */
2030} MDBX_error_t;
2031
2036MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated(void) { return MDBX_UNABLE_EXTEND_MAPSIZE; }
2037#define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
2038
2057LIBMDBX_API const char *mdbx_strerror(int errnum);
2058
2083LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2085
2086#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2091LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2092
2097LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen);
2098#endif /* Bit of Windows' madness */
2099
2115
2420
2431LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value);
2432
2443LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue);
2444
2517LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2518
2519#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2523LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode);
2524#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_openW(env, pathname, flags, mode)
2525#else
2526#define mdbx_env_openT(env, pathname, flags, mode) mdbx_env_open(env, pathname, flags, mode)
2527#endif /* Windows */
2528
2547
2568
2569#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2574LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname, MDBX_env_delete_mode_t mode);
2575#define mdbx_env_deleteT(pathname, mode) mdbx_env_deleteW(pathname, mode)
2576#else
2577#define mdbx_env_deleteT(pathname, mode) mdbx_env_delete(pathname, mode)
2578#endif /* Windows */
2579
2633LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest, MDBX_copy_flags_t flags);
2634
2689
2690#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2695LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest, MDBX_copy_flags_t flags);
2696#define mdbx_env_copyT(env, dest, flags) mdbx_env_copyW(env, dest, flags)
2697
2703#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathnameW(txn, dest, path)
2704#else
2705#define mdbx_env_copyT(env, dest, flags) mdbx_env_copy(env, dest, flags)
2706#define mdbx_txn_copy2pathnameT(txn, dest, flags) mdbx_txn_copy2pathname(txn, dest, path)
2707#endif /* Windows */
2708
2734
2759
2764 uint32_t ms_psize;
2766 uint32_t ms_depth;
2768 uint64_t ms_leaf_pages;
2770 uint64_t ms_entries;
2771 uint64_t ms_mod_txnid;
2772};
2773#ifndef __cplusplus
2775typedef struct MDBX_stat MDBX_stat;
2776#endif
2777
2797LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes);
2798
2802MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes) {
2803 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2804}
2805
2810 struct {
2811 uint64_t lower;
2812 uint64_t upper;
2813 uint64_t current;
2814 uint64_t shrink;
2815 uint64_t grow;
2817 uint64_t mi_mapsize;
2818 uint64_t mi_dxb_fsize;
2820 uint64_t mi_last_pgno;
2825 uint32_t mi_maxreaders;
2826 uint32_t mi_numreaders;
2829 uint32_t mi_sys_upcblk;
2830 uint32_t mi_sys_ioblk;
2831
2840 struct {
2841 struct {
2842 uint64_t x, y;
2843 } current, meta[3];
2845
2862 uint32_t mi_mode;
2863
2869 struct {
2870 uint64_t newly;
2871 uint64_t cow;
2872 uint64_t clone;
2874 uint64_t split;
2875 uint64_t merge;
2876 uint64_t spill;
2877 uint64_t unspill;
2878 uint64_t wops;
2880 uint64_t prefault;
2881 uint64_t mincore;
2882 uint64_t msync;
2883 uint64_t fsync;
2885
2886 /* GUID of the database DXB file. */
2887 struct {
2888 uint64_t x, y;
2890};
2891#ifndef __cplusplus
2893typedef struct MDBX_envinfo MDBX_envinfo;
2894#endif
2895
2916LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes);
2920MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes) {
2921 return mdbx_env_info_ex(env, NULL, info, bytes);
2922}
2923
2960LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2961
2965inline int mdbx_env_sync(MDBX_env * env) { return mdbx_env_sync_ex(env, true, false); }
2966
2970inline int mdbx_env_sync_poll(MDBX_env * env) { return mdbx_env_sync_ex(env, false, true); }
2971
2995inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
2996 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
2997}
2998
3013inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
3014 int rc = MDBX_EINVAL;
3015 if (threshold) {
3016 uint64_t proxy = 0;
3017 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3018#ifdef assert
3019 assert(proxy <= SIZE_MAX);
3020#endif /* assert */
3021 *threshold = (size_t)proxy;
3022 }
3023 return rc;
3024}
3025
3056inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3057 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3058}
3059
3076inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3077 int rc = MDBX_EINVAL;
3078 if (period_seconds_16dot16) {
3079 uint64_t proxy = 0;
3080 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3081#ifdef assert
3082 assert(proxy <= UINT32_MAX);
3083#endif /* assert */
3084 *period_seconds_16dot16 = (unsigned)proxy;
3085 }
3086 return rc;
3087}
3088
3128LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3129
3133inline int mdbx_env_close(MDBX_env * env) { return mdbx_env_close_ex(env, false); }
3134
3135#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3213#endif /* Windows */
3214
3263DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3264
3265
3297 unsigned timeout_seconds_16dot16);
3298
3320
3331LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3332
3346LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3347
3348#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3353LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3354#define mdbx_env_get_pathT(env, dest) mdbx_env_get_pathW(env, dest)
3355#else
3356#define mdbx_env_get_pathT(env, dest) mdbx_env_get_path(env, dest)
3357#endif /* Windows */
3358
3372
3569LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper,
3570 intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize);
3571
3574MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3575 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3576}
3577
3593LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume, intptr_t redundancy);
3594
3598
3602
3607
3612
3618
3623
3629
3634
3640 MDBX_db_flags_t flags);
3641
3648
3653
3677inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3678 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3679}
3680
3692inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3693 int rc = MDBX_EINVAL;
3694 if (readers) {
3695 uint64_t proxy = 0;
3696 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3697 *readers = (unsigned)proxy;
3698 }
3699 return rc;
3700}
3701
3723inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3724 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3725}
3726
3737inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3738 int rc = MDBX_EINVAL;
3739 if (dbs) {
3740 uint64_t proxy = 0;
3741 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3742 *dbs = (MDBX_dbi)proxy;
3743 }
3744 return rc;
3745}
3746
3752
3767LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages, intptr_t *avail_pages);
3768
3779
3790
3795
3807
3819
3830
3840
3901 void *context);
3902
3957inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn) {
3958 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3959}
3960
3972
3984
3991 uint64_t txn_id;
3992
3998
4002
4005
4009
4017
4024
4031};
4032#ifndef __cplusplus
4034typedef struct MDBX_txn_info MDBX_txn_info;
4035#endif
4036
4050LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt);
4051
4057
4068
4081
4089 uint32_t preparation;
4093 uint32_t audit;
4096 uint32_t write;
4099 uint32_t sync;
4101 uint32_t ending;
4103 uint32_t whole;
4105 uint32_t gc_cputime;
4106
4114 struct {
4117 uint32_t wloops;
4119 uint32_t coalescences;
4122 uint32_t wipes;
4126 uint32_t flushes;
4130 uint32_t kicks;
4131
4134 uint32_t work_counter;
4137 uint32_t work_rtime_monotonic;
4141 uint32_t work_xtime_cpu;
4144 uint32_t work_rsteps;
4147 uint32_t work_xpages;
4150 uint32_t work_majflt;
4151
4154 uint32_t self_counter;
4157 uint32_t self_rtime_monotonic;
4161 uint32_t self_xtime_cpu;
4164 uint32_t self_rsteps;
4167 uint32_t self_xpages;
4170 uint32_t self_majflt;
4171 /* Для разборок с pnl_merge() */
4172 struct {
4173 uint32_t time;
4174 uint64_t volume;
4175 uint32_t calls;
4176 } pnl_merge_work, pnl_merge_self;
4178};
4179#ifndef __cplusplus
4182#endif
4183
4190
4232inline int mdbx_txn_commit(MDBX_txn * txn) { return mdbx_txn_commit_ex(txn, NULL); }
4233
4268
4281
4316
4360LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4361
4403LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4404
4426
4438 uint64_t x, y, z, v;
4439};
4440#ifndef __cplusplus
4442typedef struct MDBX_canary MDBX_canary;
4443#endif
4444
4464
4476
4497typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4498
4592LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi);
4596
4615MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi,
4616 MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4619MDBX_DEPRECATED LIBMDBX_API int mdbx_dbi_open_ex2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4620 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4621
4637LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4641
4661typedef int(MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags,
4662 const struct MDBX_stat *stat, MDBX_dbi dbi) MDBX_CXX17_NOEXCEPT;
4663
4685
4698
4700
4701MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
4702
4704
4705MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
4706
4707MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
4708 return UINT64_C(0x8000000000000000) + i64;
4709}
4710
4711MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
4712 return UINT32_C(0x80000000) + i32;
4713}
4714
4715
4722
4724
4726
4728
4731
4746LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes);
4747
4763LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask);
4764
4768typedef enum MDBX_dbi_state {
4778DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
4779
4780
4791LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state);
4796inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
4797 unsigned state;
4798 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
4799}
4800
4827
4839LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
4840
4875LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data);
4876
4907LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count);
4908
4938
5020LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags);
5021
5065LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data,
5066 MDBX_put_flags_t flags);
5067
5068typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes);
5069LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data,
5070 MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver,
5071 void *preserver_context);
5072
5098LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data);
5099
5123
5134
5145
5176
5203
5217
5249
5270
5293
5316LIBMDBX_API int mdbx_txn_release_all_cursors_ex(const MDBX_txn *txn, bool unbind, size_t *count);
5317
5338inline int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind) {
5339 return mdbx_txn_release_all_cursors_ex(txn, unbind, NULL);
5340}
5341
5367
5373
5379
5391
5413LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival);
5414
5447
5462
5492typedef int(MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value, void *arg) MDBX_CXX17_NOEXCEPT;
5493
5562LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context,
5563 MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg);
5564
5650 MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value,
5651 MDBX_cursor_op turn_op, void *arg);
5652
5694LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count, MDBX_val *pairs, size_t limit,
5695 MDBX_cursor_op op);
5696
5778
5810
5831
5858LIBMDBX_API int mdbx_cursor_bunch_delete(MDBX_cursor *cursor, MDBX_bunch_action_t action, uint64_t *number_of_affected);
5859
5877LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *count);
5878
5901LIBMDBX_API int mdbx_cursor_count_ex(const MDBX_cursor *cursor, size_t *count, MDBX_stat *stat, size_t bytes);
5902
5916
5929
5942
5955
5968
5993
6013LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items);
6014
6036 ptrdiff_t *distance_items);
6037
6062LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key,
6063 const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data,
6064 ptrdiff_t *distance_items);
6065
6068#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
6069
6104
6125LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment);
6126
6143 const MDBX_val *b);
6144
6148
6165 const MDBX_val *b);
6166
6170
6196typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid,
6197 uint64_t lag, size_t bytes_used, size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6198
6211
6221
6234MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent);
6235
6255
6270
6344typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6345 unsigned gap, size_t space, int retry) MDBX_CXX17_NOEXCEPT;
6346
6366
6380
6386
6390LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
6391
6396
6406LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname, unsigned target_meta, bool writeable);
6407
6408#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6413LIBMDBX_API int mdbx_env_open_for_recoveryW(MDBX_env *env, const wchar_t *pathname, unsigned target_meta,
6414 bool writeable);
6415#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6416 mdbx_env_open_for_recoveryW(env, pathname, target_mets, writeable)
6417#else
6418#define mdbx_env_open_for_recoveryT(env, pathname, target_mets, writeable) \
6419 mdbx_env_open_for_recovery(env, pathname, target_mets, writeable)
6420#endif /* Windows */
6421
6427LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
6428
6460LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info, size_t bytes);
6461#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6466LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname, MDBX_envinfo *info, size_t bytes);
6467#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfoW(pathname, info, bytes)
6468#else
6469#define mdbx_preopen_snapinfoT(pathname, info, bytes) mdbx_preopen_snapinfo(pathname, info, bytes)
6470#endif /* Windows */
6471
6495DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
6496
6497
6515
6533
6536typedef struct MDBX_chk_line {
6537 struct MDBX_chk_context *ctx;
6539 char *begin, *end, *out;
6541
6544typedef struct MDBX_chk_issue {
6545 struct MDBX_chk_issue *next;
6546 size_t count;
6547 const char *caption;
6549
6552typedef struct MDBX_chk_scope {
6554 struct MDBX_chk_internal *internal;
6555 const void *object;
6559 union {
6560 void *ptr;
6561 size_t number;
6562 } usr_z, usr_v, usr_o;
6564
6568typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
6569
6575 struct {
6576 size_t begin, end, amount, count;
6578};
6579
6583typedef struct MDBX_chk_table {
6585
6587#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
6589#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
6591#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
6592
6595 int id;
6596
6598 struct {
6599 size_t all, empty, broken;
6600 size_t branch, leaf;
6602 } pages;
6622
6644
6660typedef struct MDBX_chk_callbacks {
6662 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, const char *fmt,
6663 va_list args);
6666 void (*issue)(MDBX_chk_context_t *ctx, const char *object, uint64_t entry_number, const char *issue,
6667 const char *extra_fmt, va_list extra_args);
6669 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err);
6671
6672 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, size_t entry_number,
6673 const MDBX_val *key, const MDBX_val *value);
6674
6677
6681 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
6682 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
6683 void (*print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix);
6685
6716 const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity,
6717 unsigned timeout_seconds_16dot16);
6718
6725
6726LIBMDBX_API const char *mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer,
6727 size_t buffer_size);
6728
6729LIBMDBX_API const char *mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size);
6730
6732
6734
6735#ifdef __cplusplus
6736} /* extern "C" */
6737#endif
6738
6739#endif /* LIBMDBX_H */
#define MDBX_NOTHROW_CONST_FUNCTION
The 'const nothrow' function attribute for optimization.
Definition mdbx.h:297
#define MDBX_CXX17_NOEXCEPT
Definition mdbx.h:411
#define MDBX_NOTHROW_PURE_FUNCTION
The 'pure nothrow' function attribute for optimization.
Definition mdbx.h:256
#define MDBX_NORETURN
Definition mdbx.h:481
uint64_t mi_mapsize
Definition mdbx.h:2817
uint32_t wipes
Количество уничтожений предыдущих надежных/устойчивых точек фиксации при работе в режиме MDBX_UTTERLY...
uint64_t txn_space_dirty
Definition mdbx.h:4030
struct MDBX_envinfo::@012005163333303136244023145022271211024347140371 mi_geo
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4105
const char * describe
uint32_t mi_dxb_pagesize
Definition mdbx.h:2827
uint32_t mi_maxreaders
Definition mdbx.h:2825
uint64_t v
Definition mdbx.h:4438
uint32_t coalescences
Количество итераций слияния записей GC.
uint32_t mi_numreaders
Definition mdbx.h:2826
uint16_t patch
Definition mdbx.h:616
const char * metadata
Definition mdbx.h:637
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2853
uint32_t self_xpages
Количество запросов на выделение последовательностей страниц для самой GC.
uint16_t major
Definition mdbx.h:614
uint64_t txn_reader_lag
Definition mdbx.h:3997
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2824
uint64_t txn_space_leftover
Definition mdbx.h:4023
struct MDBX_envinfo::@366225332126364017271247035205240304242123014254 mi_pgop_stat
uint64_t txn_space_used
Definition mdbx.h:4001
const char * datetime
Definition mdbx.h:632
uint64_t mi_recent_txnid
Definition mdbx.h:2821
uint64_t mi_autosync_threshold
Definition mdbx.h:2849
const char * semver_prerelease
Definition mdbx.h:618
uint32_t wloops
Количество итераций обновления GC, больше 1 если были повторы/перезапуски.
uint64_t ms_branch_pages
Definition mdbx.h:2767
uint64_t ms_entries
Definition mdbx.h:2770
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4091
uint16_t minor
Definition mdbx.h:615
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2859
uint64_t y
Definition mdbx.h:4438
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:4099
uint32_t mi_sys_ioblk
Definition mdbx.h:2830
uint64_t txn_space_limit_soft
Definition mdbx.h:4004
uint32_t mi_mode
Definition mdbx.h:2862
const char * options
Definition mdbx.h:634
uint64_t txn_id
Definition mdbx.h:3991
const char * sourcery
Definition mdbx.h:625
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2822
uint64_t ms_overflow_pages
Definition mdbx.h:2769
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:4089
uint32_t mi_sys_upcblk
Definition mdbx.h:2829
uint64_t z
Definition mdbx.h:4438
uint64_t txn_space_limit_hard
Definition mdbx.h:4008
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4103
uint32_t flushes
Количество принудительных фиксаций на диск во избежания приращения БД при работе вне режима MDBX_UTTE...
uint32_t work_xpages
Количество запросов на выделение последовательностей страниц ради данных пользователя.
const char * flags
Definition mdbx.h:636
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:2824
uint32_t ms_psize
Definition mdbx.h:2764
uint32_t kicks
Количество обращений к механизму Handle-Slow-Readers во избежания приращения БД.
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4093
uint16_t tweak
Definition mdbx.h:617
const char * target
Definition mdbx.h:633
uint32_t write
Duration of writing dirty/modified data pages to a filesystem, i.e. the summary duration of a write()...
Definition mdbx.h:4096
uint64_t txn_space_retired
Definition mdbx.h:4016
uint32_t ms_depth
Definition mdbx.h:2766
uint64_t mi_dxb_fallocated
Definition mdbx.h:2819
uint64_t mi_last_pgno
Definition mdbx.h:2820
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:4101
uint64_t ms_mod_txnid
Definition mdbx.h:2771
uint32_t work_rsteps
Количество итераций поиска внутри GC при выделении страниц ради данных пользователя.
const char * datetime
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2823
uint64_t ms_leaf_pages
Definition mdbx.h:2768
uint64_t mi_dxb_fsize
Definition mdbx.h:2818
uint64_t x
Definition mdbx.h:4438
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2856
uint64_t mi_unsync_volume
Definition mdbx.h:2847
uint32_t mi_sys_pagesize
Definition mdbx.h:2828
struct MDBX_version_info::@246336125106374236367351214106016351032060025144 git
uint32_t work_rtime_monotonic
Время "по настенным часам" затраченное на чтение и поиск внутри GC ради данных пользователя.
uint32_t work_xtime_cpu
Время ЦПУ в режиме пользователе затраченное на подготовку страниц извлекаемых из GC для данных пользо...
const char * compiler
Definition mdbx.h:635
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:766
mode_t mdbx_mode_t
Definition mdbx.h:171
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition mdbx.h:5068
#define LIBMDBX_API
Definition mdbx.h:588
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the table. .
Definition mdbx.h:763
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:170
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:695
int mdbx_filehandle_t
Definition mdbx.h:168
LIBMDBX_API const char * mdbx_liberr2str(int errnum)
pid_t mdbx_pid_t
Definition mdbx.h:169
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:609
@ MDBX_MAX_PAGESIZE
Definition mdbx.h:777
@ MDBX_MAXDATASIZE
Definition mdbx.h:771
@ MDBX_MAX_DBI
Definition mdbx.h:768
@ MDBX_MIN_PAGESIZE
Definition mdbx.h:774
libmdbx build information
Definition mdbx.h:631
The fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h:4437
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4086
Information about the environment.
Definition mdbx.h:2809
Statistics for a table in the environment.
Definition mdbx.h:2763
Information about the transaction.
Definition mdbx.h:3988
libmdbx version information,
Definition mdbx.h:613
MDBX_bunch_action_t
Modes for deleting bunches of neighboring items with self-documenting names.
Definition mdbx.h:5818
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:1631
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:4497
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:5492
LIBMDBX_API int mdbx_cursor_bunch_delete(MDBX_cursor *cursor, MDBX_bunch_action_t action, uint64_t *number_of_affected)
Quickly removes bunches of neighboring items.
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store items into a table.
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a table.
LIBMDBX_API int mdbx_dcmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two data items according to a particular table.
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a table.
@ MDBX_DELETE_AFTER_INCLUDING
Definition mdbx.h:5827
@ MDBX_DELETE_BEFORE_INCLUDING
Definition mdbx.h:5826
@ MDBX_DELETE_WHOLE
Definition mdbx.h:5829
@ MDBX_DELETE_BEFORE_EXCLUDING
Definition mdbx.h:5825
@ MDBX_DELETE_CURRENT_VALUE
Definition mdbx.h:5819
@ MDBX_DELETE_CURRENT_MULTIVAL_BEFORE_EXCLUDING
Definition mdbx.h:5820
@ MDBX_DELETE_AFTER_EXCLUDING
Definition mdbx.h:5828
@ MDBX_DELETE_CURRENT_MULTIVAL_ALL
Definition mdbx.h:5824
@ MDBX_DELETE_CURRENT_MULTIVAL_BEFORE_INCLUDING
Definition mdbx.h:5821
@ MDBX_DELETE_CURRENT_MULTIVAL_AFTER_INCLUDING
Definition mdbx.h:5822
@ MDBX_DELETE_CURRENT_MULTIVAL_AFTER_EXCLUDING
Definition mdbx.h:5823
@ MDBX_MULTIPLE
Definition mdbx.h:1668
@ MDBX_ALLDUPS
Definition mdbx.h:1651
@ MDBX_CURRENT
Definition mdbx.h:1646
@ MDBX_APPENDDUP
Definition mdbx.h:1664
@ MDBX_NODUPDATA
Definition mdbx.h:1640
@ MDBX_APPEND
Definition mdbx.h:1659
@ MDBX_UPSERT
Definition mdbx.h:1633
@ MDBX_RESERVE
Definition mdbx.h:1655
@ MDBX_NOOVERWRITE
Definition mdbx.h:1636
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:5338
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:1712
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:725
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:1789
@ MDBX_SEEK_AND_GET_MULTIPLE
Definition mdbx.h:1831
@ MDBX_GET_CURRENT
Definition mdbx.h:1727
@ MDBX_GET_BOTH
Definition mdbx.h:1720
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1808
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1724
@ MDBX_SET_KEY
Definition mdbx.h:1767
@ MDBX_FIRST_DUP
Definition mdbx.h:1717
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1807
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1732
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1818
@ MDBX_NEXT_NODUP
Definition mdbx.h:1752
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1815
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1816
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1823
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1775
@ MDBX_SET_RANGE
Definition mdbx.h:1770
@ MDBX_LAST_DUP
Definition mdbx.h:1738
@ MDBX_PREV
Definition mdbx.h:1755
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1825
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1826
@ MDBX_LAST
Definition mdbx.h:1735
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1806
@ MDBX_PREV_DUP
Definition mdbx.h:1758
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1814
@ MDBX_SET
Definition mdbx.h:1764
@ MDBX_NEXT
Definition mdbx.h:1741
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1809
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1822
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1749
@ MDBX_PREV_NODUP
Definition mdbx.h:1761
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1824
@ MDBX_NEXT_DUP
Definition mdbx.h:1744
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1817
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1803
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1810
@ MDBX_FIRST
Definition mdbx.h:1714
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:718
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1581
@ MDBX_INTEGERDUP
Definition mdbx.h:1605
@ MDBX_DB_ACCEDE
Definition mdbx.h:1623
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1583
@ MDBX_REVERSEKEY
Definition mdbx.h:1586
@ MDBX_DUPFIXED
Definition mdbx.h:1600
@ MDBX_INTEGERKEY
Definition mdbx.h:1596
@ MDBX_REVERSEDUP
Definition mdbx.h:1608
@ MDBX_CREATE
Definition mdbx.h:1611
@ MDBX_DUPSORT
Definition mdbx.h:1589
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:966
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:982
MDBX_log_level_t
Definition mdbx.h:840
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:899
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:882
@ MDBX_LOG_WARN
Definition mdbx.h:856
@ MDBX_LOG_TRACE
Definition mdbx.h:877
@ MDBX_LOG_DEBUG
Definition mdbx.h:872
@ MDBX_LOG_FATAL
Definition mdbx.h:844
@ MDBX_LOG_ERROR
Definition mdbx.h:850
@ MDBX_LOG_NOTICE
Definition mdbx.h:862
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:889
@ MDBX_LOG_VERBOSE
Definition mdbx.h:867
@ MDBX_DBG_ASSERT
Definition mdbx.h:905
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:927
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:923
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:920
@ MDBX_DBG_NONE
Definition mdbx.h:900
@ MDBX_DBG_DUMP
Definition mdbx.h:917
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:934
@ MDBX_DBG_AUDIT
Definition mdbx.h:909
@ MDBX_DBG_JITTER
Definition mdbx.h:913
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:6344
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1839
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:1866
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1853
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1954
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1900
@ MDBX_EACCESS
Definition mdbx.h:2010
@ MDBX_EIO
Definition mdbx.h:2018
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1859
@ MDBX_TXN_FULL
Definition mdbx.h:1884
@ MDBX_DUPLICATED_CLK
Definition mdbx.h:1974
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1869
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1951
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1965
@ MDBX_EREMOTE
Definition mdbx.h:2024
@ MDBX_TOO_LARGE
Definition mdbx.h:1958
@ MDBX_EBADSIGN
Definition mdbx.h:1947
@ MDBX_CURSOR_FULL
Definition mdbx.h:1888
@ MDBX_ENOFILE
Definition mdbx.h:2021
@ MDBX_BAD_TXN
Definition mdbx.h:1918
@ MDBX_ENODATA
Definition mdbx.h:2005
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1932
@ MDBX_CORRUPTED
Definition mdbx.h:1862
@ MDBX_EPERM
Definition mdbx.h:2019
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1962
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1971
@ MDBX_SUCCESS
Definition mdbx.h:1841
@ MDBX_NOTFOUND
Definition mdbx.h:1856
@ MDBX_RESULT_TRUE
Definition mdbx.h:1847
@ MDBX_INVALID
Definition mdbx.h:1872
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1922
@ MDBX_BUSY
Definition mdbx.h:1936
@ MDBX_OUSTED
Definition mdbx.h:1982
@ MDBX_DBS_FULL
Definition mdbx.h:1878
@ MDBX_EINVAL
Definition mdbx.h:2009
@ MDBX_BAD_RSLOT
Definition mdbx.h:1913
@ MDBX_ENOMEM
Definition mdbx.h:2011
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1939
@ MDBX_RESULT_FALSE
Definition mdbx.h:1844
@ MDBX_EINTR
Definition mdbx.h:2020
@ MDBX_READERS_FULL
Definition mdbx.h:1881
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:1988
@ MDBX_BAD_DBI
Definition mdbx.h:1926
@ MDBX_KEYEXIST
Definition mdbx.h:1850
@ MDBX_DANGLING_DBI
Definition mdbx.h:1978
@ MDBX_EDEADLK
Definition mdbx.h:2028
@ MDBX_PAGE_FULL
Definition mdbx.h:1891
@ MDBX_MAP_FULL
Definition mdbx.h:1875
@ MDBX_PROBLEM
Definition mdbx.h:1929
@ MDBX_ENOSYS
Definition mdbx.h:2014
@ MDBX_EMULTIVAL
Definition mdbx.h:1942
@ MDBX_EROFS
Definition mdbx.h:2012
@ MDBX_MVCC_RETARDED
Definition mdbx.h:1985
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1910
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:1675
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:2965
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:2970
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:2532
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:1694
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1676
@ MDBX_CP_COMPACT
Definition mdbx.h:1680
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1699
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1690
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1683
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1686
@ MDBX_CP_OVERWRITE
Definition mdbx.h:1703
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2545
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2539
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2542
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:3133
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1022
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:1237
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1023
@ MDBX_COALESCE
Definition mdbx.h:1273
@ MDBX_NOMETASYNC
Definition mdbx.h:1372
@ MDBX_LIFORECLAIM
Definition mdbx.h:1297
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1423
@ MDBX_NOTLS
Definition mdbx.h:1216
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1354
@ MDBX_PAGEPERTURB
Definition mdbx.h:1300
@ MDBX_WRITEMAP
Definition mdbx.h:1142
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1213
@ MDBX_EXCLUSIVE
Definition mdbx.h:1096
@ MDBX_NOMEMINIT
Definition mdbx.h:1260
@ MDBX_MAPASYNC
Definition mdbx.h:1430
@ MDBX_ACCEDE
Definition mdbx.h:1111
@ MDBX_NOSUBDIR
Definition mdbx.h:1048
@ MDBX_RDONLY
Definition mdbx.h:1066
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1473
@ MDBX_VALIDATION
Definition mdbx.h:1030
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:3574
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3723
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:3056
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2119
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:2995
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3219
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:3677
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:2224
@ MDBX_opt_subpage_room_threshold
Задаёт в % минимальный объём свободного места на основной странице, при отсутствии которого вложенные...
Definition mdbx.h:2397
@ MDBX_opt_subpage_limit
Задаёт в % максимальный размер вложенных страниц, используемых для размещения небольшого количества м...
Definition mdbx.h:2391
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2220
@ MDBX_opt_prefer_waf_insteadof_balance
Управляет выбором между стремлением к равномерности наполнения страниц, либо уменьшением количества и...
Definition mdbx.h:2376
@ 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:2324
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2128
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2291
@ MDBX_opt_subpage_reserve_prereq
Задаёт в % минимальный объём свободного места на основной странице, при наличии которого,...
Definition mdbx.h:2413
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2151
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2256
@ 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:2279
@ 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:2191
@ 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:2178
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2145
@ MDBX_opt_subpage_reserve_limit
Задаёт в % ограничение резервирования места на вложенных страницах.
Definition mdbx.h:2418
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2240
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2157
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2205
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2319
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2351
@ MDBX_warmup_touchlimit
Definition mdbx.h:3258
@ MDBX_warmup_force
Definition mdbx.h:3228
@ MDBX_warmup_oomsafe
Definition mdbx.h:3235
@ MDBX_warmup_release
Definition mdbx.h:3261
@ MDBX_warmup_lock
Definition mdbx.h:3250
@ MDBX_warmup_default
Definition mdbx.h:3222
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:3692
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:3076
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:4796
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:2920
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:3013
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:3601
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:4768
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:3597
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:6196
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:3737
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:2802
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:4661
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:4770
@ MDBX_DBI_FRESH
Definition mdbx.h:4774
@ MDBX_DBI_STALE
Definition mdbx.h:4772
@ MDBX_DBI_CREAT
Definition mdbx.h:4776
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:4232
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:1483
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:3957
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:706
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:1494
@ MDBX_TXN_ERROR
Definition mdbx.h:1534
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1513
@ MDBX_TXN_SPILLS
Definition mdbx.h:1544
@ MDBX_TXN_OUSTED
Definition mdbx.h:1568
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1549
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1503
@ MDBX_TXN_INVALID
Definition mdbx.h:1524
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1573
@ MDBX_TXN_PARKED
Definition mdbx.h:1554
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1517
@ MDBX_TXN_DIRTY
Definition mdbx.h:1539
@ MDBX_TXN_READWRITE
Definition mdbx.h:1488
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1561
@ MDBX_TXN_TRY
Definition mdbx.h:1509
@ MDBX_TXN_FINISHED
Definition mdbx.h:1529
MDBX_chk_severity_t verbosity
Definition mdbx.h:6557
MDBX_txn * txn
Definition mdbx.h:6628
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:6666
struct MDBX_chk_histogram tree_density
Histogram of branch and leaf pages filling in percents.
struct MDBX_chk_histogram::@167152105014034103340112155364354016331236072167 ranges[9]
void(* print_size)(MDBX_chk_line_t *, const char *prefix, const uint64_t value, const char *suffix)
Definition mdbx.h:6683
size_t pad
Definition mdbx.h:6574
void(* print_done)(MDBX_chk_line_t *)
Definition mdbx.h:6680
struct MDBX_chk_internal * internal
Definition mdbx.h:6626
uint8_t scope_nesting
Definition mdbx.h:6630
char * end
Definition mdbx.h:6539
uint8_t scope_depth
Definition mdbx.h:6538
struct MDBX_chk_histogram key_len
Keys length histogram.
struct MDBX_chk_histogram large_or_nested_density
Histogram of nested tree(s) branch and leaf pages filling in percents.
int(* stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t)
Definition mdbx.h:6675
size_t ones
Definition mdbx.h:6574
int(* stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err)
Definition mdbx.h:6676
int(* table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table, MDBX_cursor *cursor, int err)
Definition mdbx.h:6669
void(* print_format)(MDBX_chk_line_t *, const char *fmt, va_list args)
Definition mdbx.h:6682
struct MDBX_chk_internal * internal
Definition mdbx.h:6554
char * begin
Definition mdbx.h:6539
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:6662
size_t subtotal_issues
Definition mdbx.h:6558
struct MDBX_chk_histogram nested_height
Histogram of nested trees height, span length for GC.
uint8_t severity
Definition mdbx.h:6538
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:6584
void(* scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner)
Definition mdbx.h:6665
struct MDBX_chk_context * ctx
Definition mdbx.h:6537
MDBX_db_flags_t flags
Definition mdbx.h:6594
int(* scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer, MDBX_chk_scope_t *inner, int err)
Definition mdbx.h:6664
void(* print_flush)(MDBX_chk_line_t *)
Definition mdbx.h:6679
struct MDBX_chk_issue * next
Definition mdbx.h:6545
struct MDBX_chk_histogram large_pages
Histogram of large/overflow pages length.
char * out
Definition mdbx.h:6539
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:6681
const MDBX_chk_table_t *const * tables
const void * object
Definition mdbx.h:6555
size_t count
Definition mdbx.h:6574
const char * caption
Definition mdbx.h:6547
MDBX_chk_stage_t stage
Definition mdbx.h:6556
struct MDBX_chk_histogram height
Tree deep histogram.
struct MDBX_chk_histogram multival
Number of multi-values (aka duplicates) histogram.
MDBX_env * env
Definition mdbx.h:6627
uint8_t empty
Definition mdbx.h:6538
size_t amount
Definition mdbx.h:6574
MDBX_chk_scope_t * scope
Definition mdbx.h:6629
MDBX_chk_issue_t * issues
Definition mdbx.h:6553
size_t payload_bytes
Definition mdbx.h:6597
size_t count
Definition mdbx.h:6546
MDBX_val name
Definition mdbx.h:6593
size_t lost_bytes
Definition mdbx.h:6597
bool(* check_break)(MDBX_chk_context_t *ctx)
Definition mdbx.h:6661
void(* table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table)
Definition mdbx.h:6670
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:6672
int id
Definition mdbx.h:6595
LIBMDBX_API int mdbx_env_chk_encount_problem(MDBX_chk_context_t *ctx)
Вспомогательная функция для подсчета проблем детектируемых приложением, в том числе,...
LIBMDBX_API int mdbx_env_chk(MDBX_env *env, const MDBX_chk_callbacks_t *cb, MDBX_chk_context_t *ctx, const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity, unsigned timeout_seconds_16dot16)
Проверяет целостность базы данных.
LIBMDBX_API const char * mdbx_ratio2digits(uint64_t numerator, uint64_t denominator, int precision, char *buffer, size_t buffer_size)
MDBX_chk_stage_t
Стадии проверки, сообщаемые через обратные вызовы при проверке целостности базы данных.
Definition mdbx.h:6519
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
LIBMDBX_API const char * mdbx_ratio2percents(uint64_t value, uint64_t whole, char *buffer, size_t buffer_size)
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение...
Definition mdbx.h:6568
MDBX_chk_flags_t
Флаги/опции для проверки целостности базы данных.
Definition mdbx.h:6476
MDBX_chk_severity_t
Уровни логирование/детализации информации, поставляемой через обратные вызовы при проверке целостност...
Definition mdbx.h:6500
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:6525
@ MDBX_chk_init
Definition mdbx.h:6521
@ MDBX_chk_finalize
Definition mdbx.h:6531
@ MDBX_chk_space
Definition mdbx.h:6526
@ MDBX_chk_lock
Definition mdbx.h:6522
@ MDBX_chk_none
Definition mdbx.h:6520
@ MDBX_chk_maindb
Definition mdbx.h:6527
@ MDBX_chk_unlock
Definition mdbx.h:6530
@ MDBX_chk_meta
Definition mdbx.h:6523
@ MDBX_chk_conclude
Definition mdbx.h:6529
@ MDBX_chk_tree
Definition mdbx.h:6524
@ MDBX_chk_tables
Definition mdbx.h:6528
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:6485
@ MDBX_CHK_READWRITE
Definition mdbx.h:6482
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:6478
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:6488
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:6493
@ MDBX_chk_processing
Definition mdbx.h:6509
@ MDBX_chk_result
Definition mdbx.h:6507
@ MDBX_chk_details
Definition mdbx.h:6512
@ MDBX_chk_extra
Definition mdbx.h:6513
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:6501
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:6502
@ MDBX_chk_notice
Definition mdbx.h:6506
@ MDBX_chk_resolution
Definition mdbx.h:6508
@ MDBX_chk_warning
Definition mdbx.h:6505
@ MDBX_chk_fatal
Definition mdbx.h:6503
@ MDBX_chk_info
Definition mdbx.h:6510
@ MDBX_chk_error
Definition mdbx.h:6504
@ MDBX_chk_verbose
Definition mdbx.h:6511
Набор функций обратного вызова используемых при проверке целостности базы данных.
Definition mdbx.h:6660
Контекст проверки целостности базы данных.
Definition mdbx.h:6625
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД.
Definition mdbx.h:6573
Проблема обнаруженная при проверке целостности базы данных.
Definition mdbx.h:6544
Виртуальная строка отчета, формируемого при проверке целостности базы данных.
Definition mdbx.h:6536
Иерархический контекст при проверке целостности базы данных.
Definition mdbx.h:6552
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных.
Definition mdbx.h:6583
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:4707
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:4711
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)