libmdbx 0.13.1.27 (2024-10-08T18:14:15+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
 
Loading...
Searching...
No Matches
mdbx.h
Go to the documentation of this file.
1
37#pragma once
38#ifndef LIBMDBX_H
39#define LIBMDBX_H
40
41#if defined(__riscv) || defined(__riscv__) || defined(__RISCV) || \
42 defined(__RISCV__)
43#warning "The RISC-V architecture is intentionally insecure by design. \
44 Please delete this admonition at your own risk, \
45 if you make such decision informed and consciously. \
46 Refer to https://clck.ru/32d9xH for more information."
47#endif /* RISC-V */
48
49#ifdef _MSC_VER
50#pragma warning(push, 1)
51#pragma warning(disable : 4548) /* expression before comma has no effect; \
52 expected expression with side - effect */
53#pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
54 * semantics are not enabled. Specify /EHsc */
55#pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
56 * mode specified; termination on exception is \
57 * not guaranteed. Specify /EHsc */
58#endif /* _MSC_VER (warnings) */
59
60/* *INDENT-OFF* */
61/* clang-format off */
144/* *INDENT-ON* */
145/* clang-format on */
146
147#include <stdarg.h>
148#include <stddef.h>
149#include <stdint.h>
150#if !defined(NDEBUG) && !defined(assert)
151#include <assert.h>
152#endif /* NDEBUG */
153
154#if defined(_WIN32) || defined(_WIN64)
155#include <windows.h>
156#include <winnt.h>
157#ifndef __mode_t_defined
158typedef unsigned short mdbx_mode_t;
159#else
160typedef mode_t mdbx_mode_t;
161#endif /* __mode_t_defined */
162typedef HANDLE mdbx_filehandle_t;
163typedef DWORD mdbx_pid_t;
164typedef DWORD mdbx_tid_t;
165#else /* Windows */
166#include <errno.h> /* for error codes */
167#include <pthread.h> /* for pthread_t */
168#include <sys/types.h> /* for pid_t */
169#include <sys/uio.h> /* for struct iovec */
170#define HAVE_STRUCT_IOVEC 1
172typedef pid_t mdbx_pid_t;
173typedef pthread_t mdbx_tid_t;
174typedef mode_t mdbx_mode_t;
175#endif /* !Windows */
176
177#ifdef _MSC_VER
178#pragma warning(pop)
179#endif
180
186/*----------------------------------------------------------------------------*/
187
188#ifndef __has_attribute
189#define __has_attribute(x) (0)
190#endif /* __has_attribute */
191
192#ifndef __has_cpp_attribute
193#define __has_cpp_attribute(x) 0
194#endif /* __has_cpp_attribute */
195
196#ifndef __has_feature
197#define __has_feature(x) (0)
198#endif /* __has_feature */
199
200#ifndef __has_extension
201#define __has_extension(x) (0)
202#endif /* __has_extension */
203
204#ifndef __has_builtin
205#define __has_builtin(x) (0)
206#endif /* __has_builtin */
207
214#if defined(DOXYGEN)
215#define MDBX_PURE_FUNCTION [[gnu::pure]]
216#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
217 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
218 || !defined(__cplusplus) || !__has_feature(cxx_exceptions))
219#define MDBX_PURE_FUNCTION __attribute__((__pure__))
220#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
221#define MDBX_PURE_FUNCTION
222#elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure) && \
223 (!defined(__clang__) || !__has_feature(cxx_exceptions))
224#define MDBX_PURE_FUNCTION [[gnu::pure]]
225#else
226#define MDBX_PURE_FUNCTION
227#endif /* MDBX_PURE_FUNCTION */
228
232#if defined(DOXYGEN)
233#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
234#elif defined(__GNUC__) || \
235 (__has_attribute(__pure__) && __has_attribute(__nothrow__))
236#define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
237#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
238#if __has_cpp_attribute(pure)
239#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
240#else
241#define MDBX_NOTHROW_PURE_FUNCTION
242#endif
243#elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure)
244#if __has_cpp_attribute(gnu::nothrow)
245#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
246#else
247#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
248#endif
249#elif defined(__cplusplus) && __has_cpp_attribute(pure)
250#define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
251#else
252#define MDBX_NOTHROW_PURE_FUNCTION
253#endif /* MDBX_NOTHROW_PURE_FUNCTION */
254
265#if defined(DOXYGEN)
266#define MDBX_CONST_FUNCTION [[gnu::const]]
267#elif (defined(__GNUC__) || __has_attribute(__pure__)) && \
268 (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
269 || !defined(__cplusplus) || !__has_feature(cxx_exceptions))
270#define MDBX_CONST_FUNCTION __attribute__((__const__))
271#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
272#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
273#elif defined(__cplusplus) && __has_cpp_attribute(gnu::const) && \
274 (!defined(__clang__) || !__has_feature(cxx_exceptions))
275#define MDBX_CONST_FUNCTION [[gnu::const]]
276#else
277#define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
278#endif /* MDBX_CONST_FUNCTION */
279
283#if defined(DOXYGEN)
284#define MDBX_NOTHROW_CONST_FUNCTION [[gnu::const, gnu::nothrow]]
285#elif defined(__GNUC__) || \
286 (__has_attribute(__const__) && __has_attribute(__nothrow__))
287#define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
288#elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
289#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
290#elif defined(__cplusplus) && __has_cpp_attribute(gnu::const)
291#if __has_cpp_attribute(gnu::nothrow)
292#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const, gnu::nothrow]]
293#else
294#define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const]]
295#endif
296#elif defined(__cplusplus) && __has_cpp_attribute(const)
297#define MDBX_NOTHROW_CONST_FUNCTION [[const]]
298#else
299#define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
300#endif /* MDBX_NOTHROW_CONST_FUNCTION */
301
305#ifndef MDBX_DEPRECATED
306#ifdef __deprecated
307#define MDBX_DEPRECATED __deprecated
308#elif defined(DOXYGEN) || \
309 (defined(__cplusplus) && __cplusplus >= 201403L && \
310 __has_cpp_attribute(deprecated) && \
311 __has_cpp_attribute(deprecated) >= 201309L) || \
312 (!defined(__cplusplus) && defined(__STDC_VERSION__) && \
313 __STDC_VERSION__ >= 202304L)
314#define MDBX_DEPRECATED [[deprecated]]
315#elif (defined(__GNUC__) && __GNUC__ > 5) || \
316 (__has_attribute(__deprecated__) && !defined(__GNUC__))
317#define MDBX_DEPRECATED __attribute__((__deprecated__))
318#elif defined(_MSC_VER)
319#define MDBX_DEPRECATED __declspec(deprecated)
320#else
321#define MDBX_DEPRECATED
322#endif
323#endif /* MDBX_DEPRECATED */
324
325#ifndef MDBX_DEPRECATED_ENUM
326#if !defined(DOXYGEN) && (!defined(_MSC_VER) || _MSC_VER >= 1930)
327#define MDBX_DEPRECATED_ENUM MDBX_DEPRECATED
328#else
329#define MDBX_DEPRECATED_ENUM /* avoid madness MSVC */
330#endif
331#endif /* MDBX_DEPRECATED_ENUM */
332
333#ifndef __dll_export
334#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
335 defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
336#if defined(__GNUC__) || __has_attribute(__dllexport__)
337#define __dll_export __attribute__((__dllexport__))
338#elif defined(_MSC_VER)
339#define __dll_export __declspec(dllexport)
340#else
341#define __dll_export
342#endif
343#elif defined(__GNUC__) || __has_attribute(__visibility__)
344#define __dll_export __attribute__((__visibility__("default")))
345#else
346#define __dll_export
347#endif
348#endif /* __dll_export */
349
350#ifndef __dll_import
351#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
352 defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
353#if defined(__GNUC__) || __has_attribute(__dllimport__)
354#define __dll_import __attribute__((__dllimport__))
355#elif defined(_MSC_VER)
356#define __dll_import __declspec(dllimport)
357#else
358#define __dll_import
359#endif
360#else
361#define __dll_import
362#endif
363#endif /* __dll_import */
364
369#if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
370#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
371 /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
372 /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
373#else
374#define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
375#endif /* LIBMDBX_INLINE_API */
376
378#ifndef MDBX_STRINGIFY
379#define MDBX_STRINGIFY_HELPER(x) #x
380#define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
381#endif /* MDBX_STRINGIFY */
382
383/*----------------------------------------------------------------------------*/
384
385#ifndef __cplusplus
386#ifndef bool
387#define bool _Bool
388#endif
389#ifndef true
390#define true (1)
391#endif
392#ifndef false
393#define false (0)
394#endif
395#endif /* bool without __cplusplus */
396
398#if defined(DOXYGEN)
399#define MDBX_CXX17_NOEXCEPT noexcept
400#elif !defined(__cpp_noexcept_function_type) || \
401 __cpp_noexcept_function_type < 201510L
402#define MDBX_CXX17_NOEXCEPT
403#else
404#define MDBX_CXX17_NOEXCEPT noexcept
405#endif /* MDBX_CXX17_NOEXCEPT */
406
408#if defined(DOXYGEN)
409#define MDBX_CXX01_CONSTEXPR constexpr
410#define MDBX_CXX01_CONSTEXPR_VAR constexpr
411#elif !defined(__cplusplus)
412#define MDBX_CXX01_CONSTEXPR __inline
413#define MDBX_CXX01_CONSTEXPR_VAR const
414#elif !defined(DOXYGEN) && \
415 ((__cplusplus < 201103L && defined(__cpp_constexpr) && \
416 __cpp_constexpr < 200704L) || \
417 (defined(__LCC__) && __LCC__ < 124) || \
418 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
419 !defined(__clang__) && !defined(__LCC__)) || \
420 (defined(_MSC_VER) && _MSC_VER < 1910) || \
421 (defined(__clang__) && __clang_major__ < 4))
422#define MDBX_CXX01_CONSTEXPR inline
423#define MDBX_CXX01_CONSTEXPR_VAR const
424#else
425#define MDBX_CXX01_CONSTEXPR constexpr
426#define MDBX_CXX01_CONSTEXPR_VAR constexpr
427#endif /* MDBX_CXX01_CONSTEXPR */
428
431#if defined(DOXYGEN)
432#define MDBX_CXX11_CONSTEXPR constexpr
433#define MDBX_CXX11_CONSTEXPR_VAR constexpr
434#elif !defined(__cplusplus)
435#define MDBX_CXX11_CONSTEXPR __inline
436#define MDBX_CXX11_CONSTEXPR_VAR const
437#elif !defined(DOXYGEN) && \
438 (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || \
439 (defined(__LCC__) && __LCC__ < 124) || \
440 (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && \
441 !defined(__LCC__)) || \
442 (defined(_MSC_VER) && _MSC_VER < 1910) || \
443 (defined(__clang__) && __clang_major__ < 5))
444#define MDBX_CXX11_CONSTEXPR inline
445#define MDBX_CXX11_CONSTEXPR_VAR const
446#else
447#define MDBX_CXX11_CONSTEXPR constexpr
448#define MDBX_CXX11_CONSTEXPR_VAR constexpr
449#endif /* MDBX_CXX11_CONSTEXPR */
450
453#if defined(DOXYGEN)
454#define MDBX_CXX14_CONSTEXPR constexpr
455#define MDBX_CXX14_CONSTEXPR_VAR constexpr
456#elif !defined(__cplusplus)
457#define MDBX_CXX14_CONSTEXPR __inline
458#define MDBX_CXX14_CONSTEXPR_VAR const
459#elif defined(DOXYGEN) || \
460 defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
461 ((defined(_MSC_VER) && _MSC_VER >= 1910) || \
462 (defined(__clang__) && __clang_major__ > 4) || \
463 (defined(__GNUC__) && __GNUC__ > 6) || \
464 (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
465#define MDBX_CXX14_CONSTEXPR constexpr
466#define MDBX_CXX14_CONSTEXPR_VAR constexpr
467#else
468#define MDBX_CXX14_CONSTEXPR inline
469#define MDBX_CXX14_CONSTEXPR_VAR const
470#endif /* MDBX_CXX14_CONSTEXPR */
471
472#if defined(__noreturn)
473#define MDBX_NORETURN __noreturn
474#elif defined(_Noreturn)
475#define MDBX_NORETURN _Noreturn
476#elif defined(DOXYGEN) || (defined(__cplusplus) && __cplusplus >= 201103L) || \
477 (!defined(__cplusplus) && defined(__STDC_VERSION__) && \
478 __STDC_VERSION__ > 202005L)
479#define MDBX_NORETURN [[noreturn]]
480#elif defined(__GNUC__) || __has_attribute(__noreturn__)
481#define MDBX_NORETURN __attribute__((__noreturn__))
482#elif defined(_MSC_VER) && !defined(__clang__)
483#define MDBX_NORETURN __declspec(noreturn)
484#else
485#define MDBX_NORETURN
486#endif /* MDBX_NORETURN */
487
488#ifndef MDBX_PRINTF_ARGS
489#if defined(__GNUC__) || __has_attribute(__format__) || defined(DOXYGEN)
490#if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
491#define MDBX_PRINTF_ARGS(format_index, first_arg) \
492 __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
493#else
494#define MDBX_PRINTF_ARGS(format_index, first_arg) \
495 __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 && \
504 __has_cpp_attribute(maybe_unused) && \
505 __has_cpp_attribute(maybe_unused) >= 201603L) || \
506 (!defined(__cplusplus) && defined(__STDC_VERSION__) && \
507 __STDC_VERSION__ > 202005L)
508#define MDBX_MAYBE_UNUSED [[maybe_unused]]
509#elif defined(__GNUC__) || __has_attribute(__unused__)
510#define MDBX_MAYBE_UNUSED __attribute__((__unused__))
511#else
512#define MDBX_MAYBE_UNUSED
513#endif /* MDBX_MAYBE_UNUSED */
514
515#if __has_attribute(no_sanitize) || defined(DOXYGEN)
516#define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
517#else
518#define MDBX_NOSANITIZE_ENUM
519#endif /* MDBX_NOSANITIZE_ENUM */
520
521/* Oh, below are some songs and dances since:
522 * - C++ requires explicit definition of the necessary operators.
523 * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
524 * the constexpr feature which is broken in most old compilers;
525 * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
526#if !defined(DEFINE_ENUM_FLAG_OPERATORS) && !defined(DOXYGEN)
527
528#ifdef __cplusplus
529#if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \
530 (defined(__LCC__) && __LCC__ < 124) || \
531 (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
532 !defined(__clang__) && !defined(__LCC__)) || \
533 (defined(_MSC_VER) && _MSC_VER < 1910) || \
534 (defined(__clang__) && __clang_major__ < 4)
535/* The constexpr feature is not available or (may be) broken */
536#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
537#else
538/* C always allows these operators for enums */
539#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
540#endif /* __cpp_constexpr */
541
544#define DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
545 extern "C++" { \
546 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { \
547 return ENUM(unsigned(a) | unsigned(b)); \
548 } \
549 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, \
550 ENUM b) { \
551 return a = a | b; \
552 } \
553 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { \
554 return ENUM(unsigned(a) & unsigned(b)); \
555 } \
556 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, \
557 unsigned b) { \
558 return ENUM(unsigned(a) & b); \
559 } \
560 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, \
561 ENUM b) { \
562 return ENUM(a & unsigned(b)); \
563 } \
564 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, \
565 ENUM b) { \
566 return a = a & b; \
567 } \
568 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, \
569 unsigned b) { \
570 return a = a & b; \
571 } \
572 MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
573 MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { \
574 return ENUM(unsigned(a) ^ unsigned(b)); \
575 } \
576 MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, \
577 ENUM b) { \
578 return a = a ^ b; \
579 } \
580 }
581#else /* __cplusplus */
582/* nope for C since it always allows these operators for enums */
583#define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
584#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
585#endif /* !__cplusplus */
586
587#elif !defined(CONSTEXPR_ENUM_FLAGS_OPERATIONS)
588
589#ifdef __cplusplus
590/* DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
591#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
592#else
593/* C always allows these operators for enums */
594#define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
595#endif
596
597#endif /* DEFINE_ENUM_FLAG_OPERATORS */
598
601/*----------------------------------------------------------------------------*/
602
606#ifdef __cplusplus
607extern "C" {
608#endif
609
610/* MDBX version 0.13.x */
611#define MDBX_VERSION_MAJOR 0
612#define MDBX_VERSION_MINOR 13
613
614#ifndef LIBMDBX_API
615#if defined(LIBMDBX_EXPORTS)
616#define LIBMDBX_API __dll_export
617#elif defined(LIBMDBX_IMPORTS)
618#define LIBMDBX_API __dll_import
619#else
620#define LIBMDBX_API
621#endif
622#endif /* LIBMDBX_API */
623
624#ifdef __cplusplus
625#if defined(__clang__) || __has_attribute(type_visibility)
626#define LIBMDBX_API_TYPE LIBMDBX_API __attribute__((type_visibility("default")))
627#else
628#define LIBMDBX_API_TYPE LIBMDBX_API
629#endif
630#else
631#define LIBMDBX_API_TYPE
632#endif /* LIBMDBX_API_TYPE */
633
634#if defined(LIBMDBX_IMPORTS)
635#define LIBMDBX_VERINFO_API __dll_import
636#else
637#define LIBMDBX_VERINFO_API __dll_export
638#endif /* LIBMDBX_VERINFO_API */
639
642 uint8_t major;
643 uint8_t minor;
644 uint16_t release;
645 uint32_t revision;
646 struct {
647 const char *datetime;
648 const char *tree;
649 const char *commit;
650 const char *describe;
651 } git;
652 const char *sourcery;
654
659 const char *datetime;
660 const char *target;
661 const char *options;
662 const char *compiler;
663 const char *flags;
665
666#if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
667/* MDBX internally uses global and thread local storage destructors to
668 * automatically (de)initialization, releasing reader lock table slots
669 * and so on.
670 *
671 * If MDBX built as a DLL this is done out-of-the-box by DllEntry() function,
672 * which called automatically by Windows core with passing corresponding reason
673 * argument.
674 *
675 * Otherwise, if MDBX was built not as a DLL, some black magic
676 * may be required depending of Windows version:
677 *
678 * - Modern Windows versions, including Windows Vista and later, provides
679 * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
680 * or dll file). In this case, MDBX capable of doing all automatically,
681 * therefore you DON'T NEED to call mdbx_module_handler()
682 * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
683 *
684 * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
685 * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
686 * of your DLL or application,
687 * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
688 *
689 * Therefore, building MDBX as a DLL is recommended for all version of Windows.
690 * So, if you doubt, just build MDBX as the separate DLL and don't care about
691 * the MDBX_MANUAL_MODULE_HANDLER. */
692
693#ifndef _WIN32_WINNT
694#error Non-dll build libmdbx requires target Windows version \
695 to be explicitly defined via _WIN32_WINNT for properly \
696 handling thread local storage destructors.
697#endif /* _WIN32_WINNT */
698
699#if _WIN32_WINNT >= 0x0600 /* Windows Vista */
700/* As described above mdbx_module_handler() is NOT needed for Windows Vista
701 * and later. */
702#define MDBX_MANUAL_MODULE_HANDLER 0
703#else
704/* As described above mdbx_module_handler() IS REQUIRED for Windows versions
705 * prior to Windows Vista. */
706#define MDBX_MANUAL_MODULE_HANDLER 1
707void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason,
708 PVOID reserved);
709#endif
710
711#endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
712
713/* OPACITY STRUCTURES *********************************************************/
714
719#ifndef __cplusplus
720typedef struct MDBX_env MDBX_env;
721#else
722struct MDBX_env;
723#endif
724
730#ifndef __cplusplus
731typedef struct MDBX_txn MDBX_txn;
732#else
733struct MDBX_txn;
734#endif
735
743typedef uint32_t MDBX_dbi;
744
749#ifndef __cplusplus
751#else
752struct MDBX_cursor;
753#endif
754
769#ifndef HAVE_STRUCT_IOVEC
770struct iovec {
771 void *iov_base;
772 size_t iov_len;
773};
774#define HAVE_STRUCT_IOVEC
775#endif /* HAVE_STRUCT_IOVEC */
776
777#if defined(__sun) || defined(__SVR4) || defined(__svr4__)
778/* The `iov_len` is signed on Sun/Solaris.
779 * So define custom MDBX_val to avoid a lot of warnings. */
780struct MDBX_val {
781 void *iov_base;
782 size_t iov_len;
783};
784#ifndef __cplusplus
785typedef struct MDBX_val MDBX_val;
786#endif
787#else /* SunOS */
788typedef struct iovec MDBX_val;
789#endif /* ! SunOS */
790
793 MDBX_MAX_DBI = UINT32_C(32765),
794
796 MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
797
800
803};
804
805/* THE FILES *******************************************************************
806 * At the file system level, the environment corresponds to a pair of files. */
807
808#ifndef MDBX_LOCKNAME
811#if !(defined(_WIN32) || defined(_WIN64))
812#define MDBX_LOCKNAME "/mdbx.lck"
813#else
814#define MDBX_LOCKNAME_W L"\\mdbx.lck"
815#define MDBX_LOCKNAME_A "\\mdbx.lck"
816#ifdef UNICODE
817#define MDBX_LOCKNAME MDBX_LOCKNAME_W
818#else
819#define MDBX_LOCKNAME MDBX_LOCKNAME_A
820#endif /* UNICODE */
821#endif /* Windows */
822#endif /* MDBX_LOCKNAME */
823#ifndef MDBX_DATANAME
826#if !(defined(_WIN32) || defined(_WIN64))
827#define MDBX_DATANAME "/mdbx.dat"
828#else
829#define MDBX_DATANAME_W L"\\mdbx.dat"
830#define MDBX_DATANAME_A "\\mdbx.dat"
831#ifdef UNICODE
832#define MDBX_DATANAME MDBX_DATANAME_W
833#else
834#define MDBX_DATANAME MDBX_DATANAME_A
835#endif /* UNICODE */
836#endif /* Windows */
837#endif /* MDBX_DATANAME */
838
839#ifndef MDBX_LOCK_SUFFIX
841#if !(defined(_WIN32) || defined(_WIN64))
842#define MDBX_LOCK_SUFFIX "-lck"
843#else
844#define MDBX_LOCK_SUFFIX_W L"-lck"
845#define MDBX_LOCK_SUFFIX_A "-lck"
846#ifdef UNICODE
847#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_W
848#else
849#define MDBX_LOCK_SUFFIX MDBX_LOCK_SUFFIX_A
850#endif /* UNICODE */
851#endif /* Windows */
852#endif /* MDBX_LOCK_SUFFIX */
853
854/* DEBUG & LOGGING ************************************************************/
855
863typedef enum MDBX_log_level {
868
874
880
886
891
896
901
906
907#ifdef ENABLE_UBSAN
908 MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
909#endif /* ENABLE_UBSAN */
910
914
920typedef enum MDBX_debug_flags {
922
927
931
935
939
942
945
950
951#ifdef ENABLE_UBSAN
952 MDBX_DBG_MAX = ((unsigned)MDBX_LOG_MAX) << 16 |
953 127 /* avoid UBSAN false-positive trap by a tests */,
954#endif /* ENABLE_UBSAN */
955
959DEFINE_ENUM_FLAG_OPERATORS(MDBX_debug_flags)
960
961
975typedef void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function,
976 int line, const char *fmt,
977 va_list args) MDBX_CXX17_NOEXCEPT;
978
980#define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
981#define MDBX_LOGGER_NOFMT_DONTCHANGE ((MDBX_debug_func_nofmt *)(intptr_t)-1)
982
987 MDBX_debug_flags_t debug_flags,
988 MDBX_debug_func *logger);
989
991 const char *function, int line,
992 const char *msg,
993 unsigned length) MDBX_CXX17_NOEXCEPT;
994
996 MDBX_debug_flags_t debug_flags,
997 MDBX_debug_func_nofmt *logger,
998 char *logger_buffer,
999 size_t logger_buffer_size);
1000
1011typedef void MDBX_assert_func(const MDBX_env *env, const char *msg,
1012 const char *function,
1013 unsigned line) MDBX_CXX17_NOEXCEPT;
1014
1025
1035LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
1036 const size_t bufsize);
1037
1039MDBX_NORETURN LIBMDBX_API void mdbx_panic(const char *fmt, ...)
1040 MDBX_PRINTF_ARGS(1, 2);
1041
1045 const char *msg,
1046 const char *func,
1047 unsigned line);
1054typedef enum MDBX_env_flags {
1056
1062 MDBX_VALIDATION = UINT32_C(0x00002000),
1063
1080 MDBX_NOSUBDIR = UINT32_C(0x4000),
1081
1098 MDBX_RDONLY = UINT32_C(0x20000),
1099
1128 MDBX_EXCLUSIVE = UINT32_C(0x400000),
1129
1143 MDBX_ACCEDE = UINT32_C(0x40000000),
1144
1174 MDBX_WRITEMAP = UINT32_C(0x80000),
1175
1245 MDBX_NOSTICKYTHREADS = UINT32_C(0x200000),
1246
1248 MDBX_NOTLS MDBX_DEPRECATED_ENUM = MDBX_NOSTICKYTHREADS,
1249
1269 MDBX_NORDAHEAD = UINT32_C(0x800000),
1270
1292 MDBX_NOMEMINIT = UINT32_C(0x1000000),
1293
1305 MDBX_COALESCE MDBX_DEPRECATED_ENUM = UINT32_C(0x2000000),
1306
1329 MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1330
1332 MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1333
1334 /* SYNC MODES****************************************************************/
1387
1404 MDBX_NOMETASYNC = UINT32_C(0x40000),
1405
1455 MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1456
1463
1506
1509DEFINE_ENUM_FLAG_OPERATORS(MDBX_env_flags)
1510
1511
1515typedef enum MDBX_txn_flags {
1521
1527
1534#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1536#else
1537 MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1538#endif
1539
1541 MDBX_TXN_TRY = UINT32_C(0x10000000),
1542
1546
1550
1551 /* Transaction state flags ---------------------------------------------- */
1552
1556 MDBX_TXN_INVALID = INT32_MIN,
1557
1562
1567
1572
1577
1582
1587
1594
1601
1608DEFINE_ENUM_FLAG_OPERATORS(MDBX_txn_flags)
1609
1610
1614typedef enum MDBX_db_flags {
1617
1619 MDBX_REVERSEKEY = UINT32_C(0x02),
1620
1622 MDBX_DUPSORT = UINT32_C(0x04),
1623
1629 MDBX_INTEGERKEY = UINT32_C(0x08),
1630
1633 MDBX_DUPFIXED = UINT32_C(0x10),
1634
1638 MDBX_INTEGERDUP = UINT32_C(0x20),
1639
1641 MDBX_REVERSEDUP = UINT32_C(0x40),
1642
1644 MDBX_CREATE = UINT32_C(0x40000),
1645
1658DEFINE_ENUM_FLAG_OPERATORS(MDBX_db_flags)
1659
1660
1664typedef enum MDBX_put_flags {
1667
1669 MDBX_NOOVERWRITE = UINT32_C(0x10),
1670
1673 MDBX_NODUPDATA = UINT32_C(0x20),
1674
1679 MDBX_CURRENT = UINT32_C(0x40),
1680
1684 MDBX_ALLDUPS = UINT32_C(0x80),
1685
1688 MDBX_RESERVE = UINT32_C(0x10000),
1689
1692 MDBX_APPEND = UINT32_C(0x20000),
1693
1697 MDBX_APPENDDUP = UINT32_C(0x40000),
1698
1701 MDBX_MULTIPLE = UINT32_C(0x80000)
1703DEFINE_ENUM_FLAG_OPERATORS(MDBX_put_flags)
1704
1705
1735DEFINE_ENUM_FLAG_OPERATORS(MDBX_copy_flags)
1736
1737
1854
1860typedef enum MDBX_error {
1863
1866
1869
1872
1875
1878
1881
1884
1887 MDBX_PANIC = -30795,
1888
1891
1894
1897
1900
1903
1906
1910
1913
1922
1932
1936
1941
1945
1949
1952
1955
1958 MDBX_BUSY = -30778,
1959
1962
1965
1970
1974
1977
1981
1985
1988
1994
1997
2001
2004 MDBX_OUSTED = -30411,
2005
2009
2010 /* The last of MDBX-added error codes */
2012
2013#if defined(_WIN32) || defined(_WIN64)
2014 MDBX_ENODATA = ERROR_HANDLE_EOF,
2015 MDBX_EINVAL = ERROR_INVALID_PARAMETER,
2016 MDBX_EACCESS = ERROR_ACCESS_DENIED,
2017 MDBX_ENOMEM = ERROR_OUTOFMEMORY,
2018 MDBX_EROFS = ERROR_FILE_READ_ONLY,
2019 MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
2020 MDBX_EIO = ERROR_WRITE_FAULT,
2021 MDBX_EPERM = ERROR_INVALID_FUNCTION,
2022 MDBX_EINTR = ERROR_CANCELLED,
2023 MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
2024 MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR,
2025 MDBX_EDEADLK = ERROR_POSSIBLE_DEADLOCK
2026#else /* Windows */
2027#ifdef ENODATA
2028 MDBX_ENODATA = ENODATA,
2029#else
2030 MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
2031#endif /* ENODATA */
2032 MDBX_EINVAL = EINVAL,
2034 MDBX_ENOMEM = ENOMEM,
2035 MDBX_EROFS = EROFS,
2036 MDBX_ENOSYS = ENOSYS,
2038 MDBX_EPERM = EPERM,
2039 MDBX_EINTR = EINTR,
2041 MDBX_EREMOTE = ENOTBLK,
2042 MDBX_EDEADLK = EDEADLK
2043#endif /* !Windows */
2045
2050MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated(void) {
2052}
2053#define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
2054
2073LIBMDBX_API const char *mdbx_strerror(int errnum);
2074
2099LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
2101
2102#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2107LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
2108
2113LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf,
2114 size_t buflen);
2115#endif /* Bit of Windows' madness */
2116
2132
2436
2448 uint64_t value);
2449
2461 const MDBX_option_t option,
2462 uint64_t *pvalue);
2463
2536LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname,
2537 MDBX_env_flags_t flags, mdbx_mode_t mode);
2538
2539#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2543LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname,
2544 MDBX_env_flags_t flags, mdbx_mode_t mode);
2545#endif /* Windows */
2546
2565
2585LIBMDBX_API int mdbx_env_delete(const char *pathname,
2587
2588#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2593LIBMDBX_API int mdbx_env_deleteW(const wchar_t *pathname,
2595#endif /* Windows */
2596
2650LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest,
2651 MDBX_copy_flags_t flags);
2652
2707 MDBX_copy_flags_t flags);
2708
2709#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
2714LIBMDBX_API int mdbx_env_copyW(MDBX_env *env, const wchar_t *dest,
2715 MDBX_copy_flags_t flags);
2716
2721LIBMDBX_API int mdbx_txn_copy2pathnameW(MDBX_txn *txn, const wchar_t *dest,
2722 MDBX_copy_flags_t flags);
2723#endif /* Windows */
2724
2750 MDBX_copy_flags_t flags);
2751
2776 MDBX_copy_flags_t flags);
2777
2782 uint32_t ms_psize;
2784 uint32_t ms_depth;
2786 uint64_t ms_leaf_pages;
2788 uint64_t ms_entries;
2789 uint64_t ms_mod_txnid;
2790};
2791#ifndef __cplusplus
2793typedef struct MDBX_stat MDBX_stat;
2794#endif
2795
2816 MDBX_stat *stat, size_t bytes);
2817
2821MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat,
2822 size_t bytes) {
2823 return mdbx_env_stat_ex(env, NULL, stat, bytes);
2824}
2825
2830 struct {
2831 uint64_t lower;
2832 uint64_t upper;
2833 uint64_t current;
2834 uint64_t shrink;
2835 uint64_t grow;
2837 uint64_t mi_mapsize;
2838 uint64_t mi_last_pgno;
2844 uint32_t mi_maxreaders;
2845 uint32_t mi_numreaders;
2857 struct {
2858 struct {
2859 uint64_t x, y;
2860 } current, meta[3];
2862
2879 uint32_t mi_mode;
2880
2886 struct {
2887 uint64_t newly;
2888 uint64_t cow;
2889 uint64_t clone;
2891 uint64_t split;
2892 uint64_t merge;
2893 uint64_t spill;
2894 uint64_t unspill;
2895 uint64_t wops;
2897 uint64_t prefault;
2898 uint64_t mincore;
2899 uint64_t
2900 msync;
2901 uint64_t
2902 fsync;
2904
2905 /* GUID of the database DXB file. */
2906 struct {
2907 uint64_t x, y;
2909};
2910#ifndef __cplusplus
2912typedef struct MDBX_envinfo MDBX_envinfo;
2913#endif
2914
2936 MDBX_envinfo *info, size_t bytes);
2940MDBX_DEPRECATED inline int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info,
2941 size_t bytes) {
2942 return mdbx_env_info_ex(env, NULL, info, bytes);
2943}
2944
2981LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2982
2986inline int mdbx_env_sync(MDBX_env * env) {
2987 return mdbx_env_sync_ex(env, true, false);
2988}
2989
2993inline int mdbx_env_sync_poll(MDBX_env * env) {
2994 return mdbx_env_sync_ex(env, false, true);
2995}
2996
3020inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
3021 return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
3022}
3023
3038inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
3039 int rc = MDBX_EINVAL;
3040 if (threshold) {
3041 uint64_t proxy = 0;
3042 rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
3043#ifdef assert
3044 assert(proxy <= SIZE_MAX);
3045#endif /* assert */
3046 *threshold = (size_t)proxy;
3047 }
3048 return rc;
3049}
3050
3081inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
3082 return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
3083}
3084
3101inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
3102 int rc = MDBX_EINVAL;
3103 if (period_seconds_16dot16) {
3104 uint64_t proxy = 0;
3105 rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
3106#ifdef assert
3107 assert(proxy <= UINT32_MAX);
3108#endif /* assert */
3109 *period_seconds_16dot16 = (unsigned)proxy;
3110 }
3111 return rc;
3112}
3113
3153LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
3154
3158inline int mdbx_env_close(MDBX_env * env) {
3159 return mdbx_env_close_ex(env, false);
3160}
3161
3162#if defined(DOXYGEN) || !(defined(_WIN32) || defined(_WIN64))
3240#endif /* Windows */
3241
3290DEFINE_ENUM_FLAG_OPERATORS(MDBX_warmup_flags)
3291
3292
3324 MDBX_warmup_flags_t flags,
3325 unsigned timeout_seconds_16dot16);
3326
3348 bool onoff);
3349
3360LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
3361
3375LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
3376
3377#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3382LIBMDBX_API int mdbx_env_get_pathW(const MDBX_env *env, const wchar_t **dest);
3383#endif /* Windows */
3384
3398
3595LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
3596 intptr_t size_now, intptr_t size_upper,
3597 intptr_t growth_step,
3598 intptr_t shrink_threshold,
3599 intptr_t pagesize);
3600
3603MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
3604 return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
3605}
3606
3623 intptr_t redundancy);
3624
3630
3636
3641mdbx_limits_dbsize_min(intptr_t pagesize);
3642
3647mdbx_limits_dbsize_max(intptr_t pagesize);
3648
3655
3661
3668
3674
3681
3689
3694mdbx_limits_txnsize_max(intptr_t pagesize);
3695
3719inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3720 return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3721}
3722
3734inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3735 int rc = MDBX_EINVAL;
3736 if (readers) {
3737 uint64_t proxy = 0;
3738 rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3739 *readers = (unsigned)proxy;
3740 }
3741 return rc;
3742}
3743
3765inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3766 return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3767}
3768
3779inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3780 int rc = MDBX_EINVAL;
3781 if (dbs) {
3782 uint64_t proxy = 0;
3783 rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3784 *dbs = (MDBX_dbi)proxy;
3785 }
3786 return rc;
3787}
3788
3794
3809LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages,
3810 intptr_t *avail_pages);
3811
3823
3835
3839MDBX_DEPRECATED MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
3841
3854
3867
3878
3889
3950 MDBX_txn_flags_t flags, MDBX_txn **txn,
3951 void *context);
3952
4007inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags,
4008 MDBX_txn **txn) {
4009 return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
4010}
4011
4023
4036
4043 uint64_t txn_id;
4044
4050
4054
4057
4061
4069
4076
4083};
4084#ifndef __cplusplus
4086typedef struct MDBX_txn_info MDBX_txn_info;
4087#endif
4088
4103 bool scan_rlt);
4104
4111
4123
4137
4145 uint32_t preparation;
4149 uint32_t audit;
4152 uint32_t write;
4155 uint32_t sync;
4157 uint32_t ending;
4159 uint32_t whole;
4161 uint32_t gc_cputime;
4162
4170 struct {
4173 uint32_t wloops;
4175 uint32_t coalescences;
4178 uint32_t wipes;
4182 uint32_t flushes;
4186 uint32_t kicks;
4187
4190 uint32_t work_counter;
4193 uint32_t work_rtime_monotonic;
4197 uint32_t work_xtime_cpu;
4200 uint32_t work_rsteps;
4203 uint32_t work_xpages;
4206 uint32_t work_majflt;
4207
4210 uint32_t self_counter;
4213 uint32_t self_rtime_monotonic;
4217 uint32_t self_xtime_cpu;
4220 uint32_t self_rsteps;
4223 uint32_t self_xpages;
4226 uint32_t self_majflt;
4228};
4229#ifndef __cplusplus
4232#endif
4233
4240
4279inline int mdbx_txn_commit(MDBX_txn * txn) {
4280 return mdbx_txn_commit_ex(txn, NULL);
4281}
4282
4317
4330
4365
4409LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark);
4410
4452LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted);
4453
4475
4487 uint64_t x, y, z, v;
4488};
4489#ifndef __cplusplus
4491typedef struct MDBX_canary MDBX_canary;
4492#endif
4493
4513
4525
4546typedef int(MDBX_cmp_func)(const MDBX_val *a,
4547 const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
4548
4638LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name,
4639 MDBX_db_flags_t flags, MDBX_dbi *dbi);
4643 MDBX_db_flags_t flags, MDBX_dbi *dbi);
4644
4661MDBX_DEPRECATED LIBMDBX_API int
4662mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags,
4663 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4666MDBX_DEPRECATED LIBMDBX_API int
4668 MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
4669
4685LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name);
4689 const MDBX_val *name);
4690
4710typedef int(MDBX_table_enum_func)(void *ctx, const MDBX_txn *txn,
4711 const MDBX_val *name, MDBX_db_flags_t flags,
4712 const struct MDBX_stat *stat,
4714
4736 MDBX_table_enum_func *func, void *ctx);
4737
4750mdbx_key_from_jsonInteger(const int64_t json_integer);
4751
4753mdbx_key_from_double(const double ieee754_64bit);
4754
4756mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
4757
4759mdbx_key_from_float(const float ieee754_32bit);
4760
4762mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
4763
4764MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
4765 return UINT64_C(0x8000000000000000) + i64;
4766}
4767
4768MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
4769 return UINT32_C(0x80000000) + i32;
4770}
4780
4783
4786
4789
4809 MDBX_stat *stat, size_t bytes);
4810
4827 uint32_t *mask);
4828
4832typedef enum MDBX_dbi_state {
4842DEFINE_ENUM_FLAG_OPERATORS(MDBX_dbi_state)
4843
4844
4856 unsigned *flags, unsigned *state);
4861inline int mdbx_dbi_flags(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags) {
4862 unsigned state;
4863 return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
4864}
4865
4889
4901LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
4902
4937LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key,
4938 MDBX_val *data);
4939
4971 MDBX_val *data, size_t *values_count);
4972
5002 MDBX_val *key, MDBX_val *data);
5003
5086 MDBX_val *data, MDBX_put_flags_t flags);
5087
5132 MDBX_val *new_data, MDBX_val *old_data,
5133 MDBX_put_flags_t flags);
5134
5135typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target,
5136 const void *src, size_t bytes);
5138 const MDBX_val *key, MDBX_val *new_data,
5139 MDBX_val *old_data, MDBX_put_flags_t flags,
5140 MDBX_preserve_func preserver,
5141 void *preserver_context);
5142
5169 const MDBX_val *data);
5170
5194
5205
5217
5244 MDBX_dbi dbi);
5245
5268
5282
5314 MDBX_cursor **cursor);
5315
5331
5352
5378
5385
5391
5403
5426 const MDBX_cursor *right,
5427 bool ignore_multival);
5428
5461 MDBX_val *data, MDBX_cursor_op op);
5462
5477
5507typedef int(MDBX_predicate_func)(void *context, MDBX_val *key, MDBX_val *value,
5508 void *arg) MDBX_CXX17_NOEXCEPT;
5509
5579 MDBX_predicate_func *predicate, void *context,
5580 MDBX_cursor_op start_op,
5581 MDBX_cursor_op turn_op, void *arg);
5582
5668 MDBX_predicate_func *predicate,
5669 void *context, MDBX_cursor_op from_op,
5670 MDBX_val *from_key, MDBX_val *from_value,
5671 MDBX_cursor_op turn_op, void *arg);
5672
5715 MDBX_val *pairs, size_t limit,
5716 MDBX_cursor_op op);
5717
5799 MDBX_val *data, MDBX_put_flags_t flags);
5800
5832
5848LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount);
5849
5864
5878
5892
5906
5920
5966 const MDBX_cursor *last,
5967 ptrdiff_t *distance_items);
5968
5990 MDBX_val *data, MDBX_cursor_op move_op,
5991 ptrdiff_t *distance_items);
5992
6018 const MDBX_val *begin_key,
6019 const MDBX_val *begin_data,
6020 const MDBX_val *end_key,
6021 const MDBX_val *end_data,
6022 ptrdiff_t *distance_items);
6023
6026#define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
6027
6062 const void *ptr);
6063
6085LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result,
6086 uint64_t increment);
6087
6104 MDBX_dbi dbi,
6105 const MDBX_val *a,
6106 const MDBX_val *b);
6107
6112
6129 MDBX_dbi dbi,
6130 const MDBX_val *a,
6131 const MDBX_val *b);
6132
6137
6163typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid,
6164 mdbx_tid_t thread, uint64_t txnid,
6165 uint64_t lag, size_t bytes_used,
6166 size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
6167
6180 MDBX_reader_list_func *func, void *ctx);
6181
6191
6204MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn,
6205 int *percent);
6206
6226
6241
6315typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn,
6316 mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
6317 unsigned gap, size_t space,
6318 int retry) MDBX_CXX17_NOEXCEPT;
6319
6339
6354
6364LIBMDBX_API int mdbx_txn_lock(MDBX_env *env, bool dont_wait);
6365
6370
6380LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname,
6381 unsigned target_meta,
6382 bool writeable);
6383
6384#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6390 const wchar_t *pathname,
6391 unsigned target_meta,
6392 bool writeable);
6393#endif /* Windows */
6394
6400LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
6401
6433LIBMDBX_API int mdbx_preopen_snapinfo(const char *pathname, MDBX_envinfo *info,
6434 size_t bytes);
6435#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
6440LIBMDBX_API int mdbx_preopen_snapinfoW(const wchar_t *pathname,
6441 MDBX_envinfo *info, size_t bytes);
6442#endif /* Windows */
6443
6467DEFINE_ENUM_FLAG_OPERATORS(MDBX_chk_flags)
6468
6469
6487
6505
6508typedef struct MDBX_chk_line {
6509 struct MDBX_chk_context *ctx;
6510 uint8_t severity, scope_depth, empty;
6511 char *begin, *end, *out;
6513
6516typedef struct MDBX_chk_issue {
6517 struct MDBX_chk_issue *next;
6518 size_t count;
6519 const char *caption;
6521
6524typedef struct MDBX_chk_scope {
6526 struct MDBX_chk_internal *internal;
6527 const void *object;
6531 union {
6532 void *ptr;
6533 size_t number;
6534 } usr_z, usr_v, usr_o;
6536
6540typedef struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t;
6541
6547 struct {
6548 size_t begin, end, amount, count;
6550};
6551
6555typedef struct MDBX_chk_table {
6557
6559#define MDBX_CHK_MAIN ((void *)((ptrdiff_t)0))
6561#define MDBX_CHK_GC ((void *)((ptrdiff_t)-1))
6563#define MDBX_CHK_META ((void *)((ptrdiff_t)-2))
6564
6567 int id;
6568
6569 size_t payload_bytes, lost_bytes;
6570 struct {
6571 size_t all, empty, other;
6572 size_t branch, leaf;
6573 size_t nested_branch, nested_leaf, nested_subleaf;
6574 } pages;
6575 struct {
6577 struct MDBX_chk_histogram deep;
6579 struct MDBX_chk_histogram large_pages;
6581 struct MDBX_chk_histogram nested_tree;
6583 struct MDBX_chk_histogram key_len;
6585 struct MDBX_chk_histogram val_len;
6586 } histogram;
6588
6591typedef struct MDBX_chk_context {
6592 struct MDBX_chk_internal *internal;
6597 struct {
6598 size_t total_payload_bytes;
6599 size_t table_total, table_processed;
6600 size_t total_unused_bytes, unused_pages;
6601 size_t processed_pages, reclaimable_pages, gc_pages, alloc_pages,
6602 backed_pages;
6603 size_t problems_meta, tree_problems, gc_tree_problems, kv_tree_problems,
6604 problems_gc, problems_kv, total_problems;
6605 uint64_t steady_txnid, recent_txnid;
6609 const MDBX_chk_table_t *const *tables;
6610 } result;
6612
6628typedef struct MDBX_chk_callbacks {
6629 bool (*check_break)(MDBX_chk_context_t *ctx);
6630 int (*scope_push)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer,
6631 MDBX_chk_scope_t *inner, const char *fmt, va_list args);
6632 int (*scope_conclude)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer,
6633 MDBX_chk_scope_t *inner, int err);
6634 void (*scope_pop)(MDBX_chk_context_t *ctx, MDBX_chk_scope_t *outer,
6635 MDBX_chk_scope_t *inner);
6636 void (*issue)(MDBX_chk_context_t *ctx, const char *object,
6637 uint64_t entry_number, const char *issue, const char *extra_fmt,
6638 va_list extra_args);
6640 const MDBX_val *name,
6641 MDBX_db_flags_t flags);
6642 int (*table_conclude)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table,
6643 MDBX_cursor *cursor, int err);
6644 void (*table_dispose)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table);
6645
6646 int (*table_handle_kv)(MDBX_chk_context_t *ctx, const MDBX_chk_table_t *table,
6647 size_t entry_number, const MDBX_val *key,
6648 const MDBX_val *value);
6649
6650 int (*stage_begin)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t);
6651 int (*stage_end)(MDBX_chk_context_t *ctx, MDBX_chk_stage_t, int err);
6652
6654 MDBX_chk_severity_t severity);
6655 void (*print_flush)(MDBX_chk_line_t *);
6656 void (*print_done)(MDBX_chk_line_t *);
6657 void (*print_chars)(MDBX_chk_line_t *, const char *str, size_t len);
6658 void (*print_format)(MDBX_chk_line_t *, const char *fmt, va_list args);
6659 void (*print_size)(MDBX_chk_line_t *, const char *prefix,
6660 const uint64_t value, const char *suffix);
6662
6693 MDBX_chk_context_t *ctx,
6694 const MDBX_chk_flags_t flags,
6695 MDBX_chk_severity_t verbosity,
6696 unsigned timeout_seconds_16dot16);
6697
6704
6709#ifdef __cplusplus
6710} /* extern "C" */
6711#endif
6712
6713#endif /* LIBMDBX_H */
#define MDBX_NOTHROW_CONST_FUNCTION
The 'const nothrow' function attribute for optimization.
Definition mdbx.h:284
#define MDBX_CXX17_NOEXCEPT
Definition mdbx.h:399
#define MDBX_NOTHROW_PURE_FUNCTION
The 'pure nothrow' function attribute for optimization.
Definition mdbx.h:233
#define MDBX_NORETURN
Definition mdbx.h:479
uint64_t mi_mapsize
Definition mdbx.h:2837
uint64_t txn_space_dirty
Definition mdbx.h:4082
uint32_t gc_cputime
User-mode CPU time spent on GC update.
Definition mdbx.h:4161
uint32_t mi_dxb_pagesize
Definition mdbx.h:2846
uint32_t mi_maxreaders
Definition mdbx.h:2844
uint64_t v
Definition mdbx.h:4487
uint32_t mi_numreaders
Definition mdbx.h:2845
struct MDBX_envinfo::@3 mi_pgop_stat
uint32_t mi_since_sync_seconds16dot16
Definition mdbx.h:2870
uint64_t txn_reader_lag
Definition mdbx.h:4049
uint64_t mi_meta_txnid[3]
Definition mdbx.h:2843
struct MDBX_envinfo::@2 mi_bootid
A mostly unique ID that is regenerated on each boot.
uint64_t txn_space_leftover
Definition mdbx.h:4075
uint64_t txn_space_used
Definition mdbx.h:4053
const char * datetime
Definition mdbx.h:659
uint16_t release
Definition mdbx.h:644
uint64_t mi_recent_txnid
Definition mdbx.h:2839
uint64_t mi_autosync_threshold
Definition mdbx.h:2866
uint64_t ms_branch_pages
Definition mdbx.h:2785
uint64_t ms_entries
Definition mdbx.h:2788
uint32_t gc_wallclock
Duration of GC update by wall clock.
Definition mdbx.h:4147
struct MDBX_commit_latency::@6 gc_prof
Информация для профилирования работы GC.
uint32_t mi_since_reader_check_seconds16dot16
Definition mdbx.h:2876
uint64_t y
Definition mdbx.h:4487
uint32_t revision
Definition mdbx.h:645
uint8_t minor
Definition mdbx.h:643
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:4155
uint64_t txn_space_limit_soft
Definition mdbx.h:4056
uint32_t mi_mode
Definition mdbx.h:2879
const char * options
Definition mdbx.h:661
uint64_t txn_id
Definition mdbx.h:4043
const char * sourcery
Definition mdbx.h:652
uint8_t major
Definition mdbx.h:642
uint64_t mi_latter_reader_txnid
Definition mdbx.h:2840
struct MDBX_envinfo::@1 mi_geo
uint64_t ms_overflow_pages
Definition mdbx.h:2787
uint32_t preparation
Duration of preparation (commit child transactions, update table's records and cursors destroying).
Definition mdbx.h:4145
uint64_t z
Definition mdbx.h:4487
uint64_t txn_space_limit_hard
Definition mdbx.h:4060
uint32_t whole
The total duration of a commit.
Definition mdbx.h:4159
const char * flags
Definition mdbx.h:663
uint64_t mi_meta_sign[3]
Definition mdbx.h:2843
uint32_t ms_psize
Definition mdbx.h:2782
uint32_t audit
Duration of internal audit if enabled.
Definition mdbx.h:4149
const char * target
Definition mdbx.h:660
uint32_t write
Duration of writing dirty/modified data pages to a filesystem, i.e. the summary duration of a write()...
Definition mdbx.h:4152
uint64_t txn_space_retired
Definition mdbx.h:4068
uint32_t ms_depth
Definition mdbx.h:2784
struct MDBX_version_info::@0 git
uint64_t mi_last_pgno
Definition mdbx.h:2838
uint32_t ending
Duration of transaction ending (releasing resources).
Definition mdbx.h:4157
uint64_t ms_mod_txnid
Definition mdbx.h:2789
uint64_t mi_self_latter_reader_txnid
Definition mdbx.h:2841
uint64_t ms_leaf_pages
Definition mdbx.h:2786
uint64_t x
Definition mdbx.h:4487
uint32_t mi_autosync_period_seconds16dot16
Definition mdbx.h:2873
uint64_t mi_unsync_volume
Definition mdbx.h:2864
uint32_t mi_sys_pagesize
Definition mdbx.h:2847
struct MDBX_envinfo::@4 mi_dxbid
const char * compiler
Definition mdbx.h:662
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:791
mode_t mdbx_mode_t
Definition mdbx.h:174
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition mdbx.h:5135
#define LIBMDBX_API
Definition mdbx.h:620
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the table. .
Definition mdbx.h:788
LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver, void *preserver_context)
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
pthread_t mdbx_tid_t
Definition mdbx.h:173
LIBMDBX_VERINFO_API const struct MDBX_build_info mdbx_build
libmdbx build information
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition mdbx.h:720
int mdbx_filehandle_t
Definition mdbx.h:171
LIBMDBX_API const char * mdbx_liberr2str(int errnum)
pid_t mdbx_pid_t
Definition mdbx.h:172
LIBMDBX_API int mdbx_env_openW(MDBX_env *env, const wchar_t *pathname, MDBX_env_flags_t flags, mdbx_mode_t mode)
Open an environment instance.
#define LIBMDBX_VERINFO_API
Definition mdbx.h:637
@ MDBX_MAX_PAGESIZE
Definition mdbx.h:802
@ MDBX_MAXDATASIZE
Definition mdbx.h:796
@ MDBX_MAX_DBI
Definition mdbx.h:793
@ MDBX_MIN_PAGESIZE
Definition mdbx.h:799
libmdbx build information
Definition mdbx.h:658
The fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h:4486
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4142
Information about the environment.
Definition mdbx.h:2829
Statistics for a table in the environment.
Definition mdbx.h:2781
Information about the transaction.
Definition mdbx.h:4040
libmdbx version information
Definition mdbx.h:641
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.
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:5507
MDBX_put_flags_t
Data changing flags.
Definition mdbx.h:1664
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.
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:4546
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.
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.
LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount)
Return count of duplicates for current key.
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store items into a table.
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a table.
LIBMDBX_API int mdbx_dcmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two data items according to a particular table.
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a table.
@ MDBX_MULTIPLE
Definition mdbx.h:1701
@ MDBX_ALLDUPS
Definition mdbx.h:1684
@ MDBX_CURRENT
Definition mdbx.h:1679
@ MDBX_APPENDDUP
Definition mdbx.h:1697
@ MDBX_NODUPDATA
Definition mdbx.h:1673
@ MDBX_APPEND
Definition mdbx.h:1692
@ MDBX_UPSERT
Definition mdbx.h:1666
@ MDBX_RESERVE
Definition mdbx.h:1688
@ MDBX_NOOVERWRITE
Definition mdbx.h:1669
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу.
LIBMDBX_API int mdbx_cursor_renew(const MDBX_txn *txn, MDBX_cursor *cursor)
Renew a cursor handle for use within the given transaction.
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:1741
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_reset(MDBX_cursor *cursor)
Сбрасывает состояние курсора.
struct MDBX_cursor MDBX_cursor
Opaque structure for navigating through a table.
Definition mdbx.h:750
LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx)
Set application information associated with the cursor.
LIBMDBX_API int mdbx_cursor_open(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor)
Create a cursor handle for the specified transaction and DBI handle.
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_bind(const MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi)
Bind cursor to specified transaction and DBI-handle.
LIBMDBX_API void * mdbx_cursor_get_userctx(const MDBX_cursor *cursor)
Get the application information associated with the MDBX_cursor.
LIBMDBX_API void mdbx_cursor_close(MDBX_cursor *cursor)
Close a cursor handle.
LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
LIBMDBX_API int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind)
Unbind or closes all cursors of a given transaction.
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:1817
@ MDBX_GET_CURRENT
Definition mdbx.h:1756
@ MDBX_GET_BOTH
Definition mdbx.h:1749
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1836
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1753
@ MDBX_SET_KEY
Definition mdbx.h:1796
@ MDBX_FIRST_DUP
Definition mdbx.h:1746
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1835
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1761
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1846
@ MDBX_NEXT_NODUP
Definition mdbx.h:1781
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1843
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1844
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1849
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1803
@ MDBX_SET_RANGE
Definition mdbx.h:1799
@ MDBX_LAST_DUP
Definition mdbx.h:1767
@ MDBX_PREV
Definition mdbx.h:1784
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1851
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1852
@ MDBX_LAST
Definition mdbx.h:1764
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1834
@ MDBX_PREV_DUP
Definition mdbx.h:1787
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1842
@ MDBX_SET
Definition mdbx.h:1793
@ MDBX_NEXT
Definition mdbx.h:1770
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1837
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1848
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1778
@ MDBX_PREV_NODUP
Definition mdbx.h:1790
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1850
@ MDBX_NEXT_DUP
Definition mdbx.h:1773
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1845
@ MDBX_SET_UPPERBOUND
Definition mdbx.h:1831
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1838
@ MDBX_FIRST
Definition mdbx.h:1743
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:743
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1614
@ MDBX_INTEGERDUP
Definition mdbx.h:1638
@ MDBX_DB_ACCEDE
Definition mdbx.h:1656
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1616
@ MDBX_REVERSEKEY
Definition mdbx.h:1619
@ MDBX_DUPFIXED
Definition mdbx.h:1633
@ MDBX_INTEGERKEY
Definition mdbx.h:1629
@ MDBX_REVERSEDUP
Definition mdbx.h:1641
@ MDBX_CREATE
Definition mdbx.h:1644
@ MDBX_DUPSORT
Definition mdbx.h:1622
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:990
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:1011
MDBX_log_level_t
Definition mdbx.h:863
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:920
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:975
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:905
@ MDBX_LOG_WARN
Definition mdbx.h:879
@ MDBX_LOG_TRACE
Definition mdbx.h:900
@ MDBX_LOG_DEBUG
Definition mdbx.h:895
@ MDBX_LOG_FATAL
Definition mdbx.h:867
@ MDBX_LOG_ERROR
Definition mdbx.h:873
@ MDBX_LOG_NOTICE
Definition mdbx.h:885
@ MDBX_LOG_DONTCHANGE
Definition mdbx.h:912
@ MDBX_LOG_VERBOSE
Definition mdbx.h:890
@ MDBX_DBG_ASSERT
Definition mdbx.h:926
@ MDBX_DBG_DONT_UPGRADE
Definition mdbx.h:949
@ MDBX_DBG_LEGACY_OVERLAP
Definition mdbx.h:944
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition mdbx.h:941
@ MDBX_DBG_NONE
Definition mdbx.h:921
@ MDBX_DBG_DUMP
Definition mdbx.h:938
@ MDBX_DBG_DONTCHANGE
Definition mdbx.h:957
@ MDBX_DBG_AUDIT
Definition mdbx.h:930
@ MDBX_DBG_JITTER
Definition mdbx.h:934
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 ...
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:6315
LIBMDBX_API const char * mdbx_strerror(int errnum)
Return a string describing a given error code.
LIBMDBX_API const char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1860
LIBMDBX_API 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:1887
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1874
@ MDBX_EKEYMISMATCH
Definition mdbx.h:1976
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition mdbx.h:1921
@ MDBX_EACCESS
Definition mdbx.h:2033
@ MDBX_EIO
Definition mdbx.h:2037
@ MDBX_PAGE_NOTFOUND
Definition mdbx.h:1880
@ MDBX_TXN_FULL
Definition mdbx.h:1905
@ MDBX_DUPLICATED_CLK
Definition mdbx.h:1996
@ MDBX_VERSION_MISMATCH
Definition mdbx.h:1890
@ MDBX_WANNA_RECOVERY
Definition mdbx.h:1973
@ MDBX_TXN_OVERLAPPING
Definition mdbx.h:1987
@ MDBX_EREMOTE
Definition mdbx.h:2041
@ MDBX_TOO_LARGE
Definition mdbx.h:1980
@ MDBX_EBADSIGN
Definition mdbx.h:1969
@ MDBX_CURSOR_FULL
Definition mdbx.h:1909
@ MDBX_ENOFILE
Definition mdbx.h:2040
@ MDBX_BAD_TXN
Definition mdbx.h:1940
@ MDBX_ENODATA
Definition mdbx.h:2030
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1954
@ MDBX_CORRUPTED
Definition mdbx.h:1883
@ MDBX_EPERM
Definition mdbx.h:2038
@ MDBX_THREAD_MISMATCH
Definition mdbx.h:1984
@ MDBX_BACKLOG_DEPLETED
Definition mdbx.h:1993
@ MDBX_SUCCESS
Definition mdbx.h:1862
@ MDBX_NOTFOUND
Definition mdbx.h:1877
@ MDBX_RESULT_TRUE
Definition mdbx.h:1868
@ MDBX_INVALID
Definition mdbx.h:1893
@ MDBX_BAD_VALSIZE
Definition mdbx.h:1944
@ MDBX_BUSY
Definition mdbx.h:1958
@ MDBX_OUSTED
Definition mdbx.h:2004
@ MDBX_DBS_FULL
Definition mdbx.h:1899
@ MDBX_EINVAL
Definition mdbx.h:2032
@ MDBX_BAD_RSLOT
Definition mdbx.h:1935
@ MDBX_ENOMEM
Definition mdbx.h:2034
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1961
@ MDBX_RESULT_FALSE
Definition mdbx.h:1865
@ MDBX_EINTR
Definition mdbx.h:2039
@ MDBX_READERS_FULL
Definition mdbx.h:1902
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:2011
@ MDBX_BAD_DBI
Definition mdbx.h:1948
@ MDBX_KEYEXIST
Definition mdbx.h:1871
@ MDBX_DANGLING_DBI
Definition mdbx.h:2000
@ MDBX_EDEADLK
Definition mdbx.h:2042
@ MDBX_PAGE_FULL
Definition mdbx.h:1912
@ MDBX_MAP_FULL
Definition mdbx.h:1896
@ MDBX_PROBLEM
Definition mdbx.h:1951
@ MDBX_ENOSYS
Definition mdbx.h:2036
@ MDBX_EMULTIVAL
Definition mdbx.h:1964
@ MDBX_EROFS
Definition mdbx.h:2035
@ MDBX_MVCC_RETARDED
Definition mdbx.h:2008
@ MDBX_INCOMPATIBLE
Definition mdbx.h:1931
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:1708
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:2986
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:2993
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:2550
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:1727
@ MDBX_CP_DEFAULTS
Definition mdbx.h:1709
@ MDBX_CP_COMPACT
Definition mdbx.h:1713
@ MDBX_CP_RENEW_TXN
Definition mdbx.h:1732
@ MDBX_CP_THROTTLE_MVCC
Definition mdbx.h:1723
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition mdbx.h:1716
@ MDBX_CP_DONT_FLUSH
Definition mdbx.h:1719
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition mdbx.h:2563
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition mdbx.h:2557
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition mdbx.h:2560
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:3158
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1054
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:1269
@ MDBX_ENV_DEFAULTS
Definition mdbx.h:1055
@ MDBX_COALESCE
Definition mdbx.h:1305
@ MDBX_NOMETASYNC
Definition mdbx.h:1404
@ MDBX_LIFORECLAIM
Definition mdbx.h:1329
@ MDBX_SAFE_NOSYNC
Definition mdbx.h:1455
@ MDBX_NOTLS
Definition mdbx.h:1248
@ MDBX_SYNC_DURABLE
Definition mdbx.h:1386
@ MDBX_PAGEPERTURB
Definition mdbx.h:1332
@ MDBX_WRITEMAP
Definition mdbx.h:1174
@ MDBX_NOSTICKYTHREADS
Definition mdbx.h:1245
@ MDBX_EXCLUSIVE
Definition mdbx.h:1128
@ MDBX_NOMEMINIT
Definition mdbx.h:1292
@ MDBX_MAPASYNC
Definition mdbx.h:1462
@ MDBX_ACCEDE
Definition mdbx.h:1143
@ MDBX_NOSUBDIR
Definition mdbx.h:1080
@ MDBX_RDONLY
Definition mdbx.h:1098
@ MDBX_UTTERLY_NOSYNC
Definition mdbx.h:1505
@ MDBX_VALIDATION
Definition mdbx.h:1062
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:3603
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named tables for the environment.
Definition mdbx.h:3765
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:3081
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2136
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper, intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize)
Set all size-related parameters of environment, including page size and the min/max size of the memor...
int mdbx_env_set_syncbytes(MDBX_env *env, size_t threshold)
Sets threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the envi...
Definition mdbx.h:3020
MDBX_warmup_flags_t
Warming up options.
Definition mdbx.h:3246
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:3719
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:2240
@ MDBX_opt_subpage_room_threshold
Задаёт в % минимальный объём свободного места на основной странице, при отсутствии которого вложенные...
Definition mdbx.h:2413
@ MDBX_opt_subpage_limit
Задаёт в % максимальный размер вложенных страниц, используемых для размещения небольшого количества м...
Definition mdbx.h:2407
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2236
@ MDBX_opt_prefer_waf_insteadof_balance
Управляет выбором между стремлением к равномерности наполнения страниц, либо уменьшением количества и...
Definition mdbx.h:2392
@ 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:2340
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2145
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2307
@ MDBX_opt_subpage_reserve_prereq
Задаёт в % минимальный объём свободного места на основной странице, при наличии которого,...
Definition mdbx.h:2429
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2168
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2272
@ 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:2295
@ MDBX_opt_loose_limit
Controls the in-process limit to grow a cache of dirty pages for reuse in the current transaction.
Definition mdbx.h:2208
@ MDBX_opt_rp_augment_limit
Controls the in-process limit to grow a list of reclaimed/recycled page's numbers for finding a seque...
Definition mdbx.h:2195
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2162
@ MDBX_opt_subpage_reserve_limit
Задаёт в % ограничение резервирования места на вложенных страницах.
Definition mdbx.h:2434
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2256
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2174
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2222
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2335
@ MDBX_opt_gc_time_limit
Controls the in-process spending time limit of searching consecutive pages inside GC.
Definition mdbx.h:2367
@ MDBX_warmup_touchlimit
Definition mdbx.h:3285
@ MDBX_warmup_force
Definition mdbx.h:3255
@ MDBX_warmup_oomsafe
Definition mdbx.h:3262
@ MDBX_warmup_release
Definition mdbx.h:3288
@ MDBX_warmup_lock
Definition mdbx.h:3277
@ MDBX_warmup_default
Definition mdbx.h:3249
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:3734
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:3101
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:4861
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:2940
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:3038
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:3633
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:4832
LIBMDBX_API int mdbx_env_get_valsize4page_max(const MDBX_env *env, MDBX_db_flags_t flags)
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified ...
intptr_t mdbx_limits_pgsize_min(void)
Returns the minimal database page size in bytes.
Definition mdbx.h:3627
LIBMDBX_API int mdbx_env_get_maxkeysize(const MDBX_env *env)
LIBMDBX_API int mdbx_env_get_fd(const MDBX_env *env, mdbx_filehandle_t *fd)
Return the file descriptor for the given environment.
LIBMDBX_API void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
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:4710
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:6163
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:3779
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:2821
LIBMDBX_API intptr_t mdbx_limits_pairsize4page_max(intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal size of key-value pair to fit in a single page with the given size and table flags,...
LIBMDBX_API intptr_t mdbx_limits_dbsize_max(intptr_t pagesize)
Returns maximal database size in bytes for given page size, or -1 if pagesize is invalid.
LIBMDBX_API intptr_t mdbx_limits_dbsize_min(intptr_t pagesize)
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags)
Get environment flags.
LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state)
Retrieve the DB flags and status for a table handle.
@ MDBX_DBI_DIRTY
Definition mdbx.h:4834
@ MDBX_DBI_FRESH
Definition mdbx.h:4838
@ MDBX_DBI_STALE
Definition mdbx.h:4836
@ MDBX_DBI_CREAT
Definition mdbx.h:4840
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken.
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:4279
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:1515
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:4007
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:731
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:1526
@ MDBX_TXN_ERROR
Definition mdbx.h:1566
@ MDBX_TXN_NOMETASYNC
Definition mdbx.h:1545
@ MDBX_TXN_SPILLS
Definition mdbx.h:1576
@ MDBX_TXN_OUSTED
Definition mdbx.h:1600
@ MDBX_TXN_HAS_CHILD
Definition mdbx.h:1581
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1535
@ MDBX_TXN_INVALID
Definition mdbx.h:1556
@ MDBX_TXN_BLOCKED
Definition mdbx.h:1605
@ MDBX_TXN_PARKED
Definition mdbx.h:1586
@ MDBX_TXN_NOSYNC
Definition mdbx.h:1549
@ MDBX_TXN_DIRTY
Definition mdbx.h:1571
@ MDBX_TXN_READWRITE
Definition mdbx.h:1520
@ MDBX_TXN_AUTOUNPARK
Definition mdbx.h:1593
@ MDBX_TXN_TRY
Definition mdbx.h:1541
@ MDBX_TXN_FINISHED
Definition mdbx.h:1561
MDBX_chk_severity_t verbosity
Definition mdbx.h:6529
MDBX_txn * txn
Definition mdbx.h:6594
size_t pad
Definition mdbx.h:6546
struct MDBX_chk_internal * internal
Definition mdbx.h:6592
uint8_t scope_nesting
Definition mdbx.h:6596
size_t ones
Definition mdbx.h:6546
struct MDBX_chk_histogram::@8 ranges[9]
struct MDBX_chk_internal * internal
Definition mdbx.h:6526
char * begin
Definition mdbx.h:6511
size_t subtotal_issues
Definition mdbx.h:6530
MDBX_chk_user_table_cookie_t * cookie
Definition mdbx.h:6556
struct MDBX_chk_context * ctx
Definition mdbx.h:6509
MDBX_db_flags_t flags
Definition mdbx.h:6566
struct MDBX_chk_issue * next
Definition mdbx.h:6517
const void * object
Definition mdbx.h:6527
size_t count
Definition mdbx.h:6546
const char * caption
Definition mdbx.h:6519
MDBX_chk_stage_t stage
Definition mdbx.h:6528
MDBX_env * env
Definition mdbx.h:6593
uint8_t empty
Definition mdbx.h:6510
size_t amount
Definition mdbx.h:6546
MDBX_chk_scope_t * scope
Definition mdbx.h:6595
MDBX_chk_issue_t * issues
Definition mdbx.h:6525
size_t count
Definition mdbx.h:6518
MDBX_val name
Definition mdbx.h:6565
size_t lost_bytes
Definition mdbx.h:6569
int id
Definition mdbx.h:6567
LIBMDBX_API int mdbx_env_chk_encount_problem(MDBX_chk_context_t *ctx)
Вспомогательная функция для подсчета проблем детектируемых приложением, в том числе,...
LIBMDBX_API int mdbx_env_chk(MDBX_env *env, const MDBX_chk_callbacks_t *cb, MDBX_chk_context_t *ctx, const MDBX_chk_flags_t flags, MDBX_chk_severity_t verbosity, unsigned timeout_seconds_16dot16)
Проверяет целостность базы данных.
MDBX_chk_stage_t
Стадии проверки, сообщаемые через обратные вызовы при проверке целостности базы данных.
Definition mdbx.h:6491
LIBMDBX_API int mdbx_txn_unlock(MDBX_env *env)
Releases write-transaction lock. Provided for custom and/or complex locking scenarios.
struct MDBX_chk_user_table_cookie MDBX_chk_user_table_cookie_t
Пользовательский тип для привязки дополнительных данных, связанных с некоторой таблицей ключ-значение...
Definition mdbx.h:6540
MDBX_chk_flags_t
Флаги/опции для проверки целостности базы данных.
Definition mdbx.h:6448
MDBX_chk_severity_t
Уровни логирование/детализации информации, поставляемой через обратные вызовы при проверке целостност...
Definition mdbx.h:6472
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:6497
@ MDBX_chk_init
Definition mdbx.h:6493
@ MDBX_chk_finalize
Definition mdbx.h:6503
@ MDBX_chk_space
Definition mdbx.h:6498
@ MDBX_chk_lock
Definition mdbx.h:6494
@ MDBX_chk_none
Definition mdbx.h:6492
@ MDBX_chk_maindb
Definition mdbx.h:6499
@ MDBX_chk_unlock
Definition mdbx.h:6502
@ MDBX_chk_meta
Definition mdbx.h:6495
@ MDBX_chk_conclude
Definition mdbx.h:6501
@ MDBX_chk_tree
Definition mdbx.h:6496
@ MDBX_chk_tables
Definition mdbx.h:6500
@ MDBX_CHK_SKIP_BTREE_TRAVERSAL
Definition mdbx.h:6457
@ MDBX_CHK_READWRITE
Definition mdbx.h:6454
@ MDBX_CHK_DEFAULTS
Definition mdbx.h:6450
@ MDBX_CHK_SKIP_KV_TRAVERSAL
Definition mdbx.h:6460
@ MDBX_CHK_IGNORE_ORDER
Definition mdbx.h:6465
@ MDBX_chk_processing
Definition mdbx.h:6481
@ MDBX_chk_result
Definition mdbx.h:6479
@ MDBX_chk_details
Definition mdbx.h:6484
@ MDBX_chk_extra
Definition mdbx.h:6485
@ MDBX_chk_severity_prio_shift
Definition mdbx.h:6473
@ MDBX_chk_severity_kind_mask
Definition mdbx.h:6474
@ MDBX_chk_notice
Definition mdbx.h:6478
@ MDBX_chk_resolution
Definition mdbx.h:6480
@ MDBX_chk_warning
Definition mdbx.h:6477
@ MDBX_chk_fatal
Definition mdbx.h:6475
@ MDBX_chk_info
Definition mdbx.h:6482
@ MDBX_chk_error
Definition mdbx.h:6476
@ MDBX_chk_verbose
Definition mdbx.h:6483
Набор функций обратного вызова используемых при проверке целостности базы данных.
Definition mdbx.h:6628
Контекст проверки целостности базы данных.
Definition mdbx.h:6591
Гистограмма с некоторой статистической информацией, собираемой при проверке целостности БД.
Definition mdbx.h:6545
Проблема обнаруженная при проверке целостности базы данных.
Definition mdbx.h:6516
Виртуальная строка отчета, формируемого при проверке целостности базы данных.
Definition mdbx.h:6508
Иерархический контекст при проверке целостности базы данных.
Definition mdbx.h:6524
Информация о некоторой таблицей ключ-значение, при проверке целостности базы данных.
Definition mdbx.h:6555
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:4764
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:4768
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)