libmdbx  0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
mdbx.h
Go to the documentation of this file.
1 
68 #pragma once
69 #ifndef LIBMDBX_H
70 #define LIBMDBX_H
71 
72 #ifdef _MSC_VER
73 #pragma warning(push, 1)
74 #pragma warning(disable : 4548) /* expression before comma has no effect; \
75  expected expression with side - effect */
76 #pragma warning(disable : 4530) /* C++ exception handler used, but unwind \
77  * semantics are not enabled. Specify /EHsc */
78 #pragma warning(disable : 4577) /* 'noexcept' used with no exception handling \
79  * mode specified; termination on exception is \
80  * not guaranteed. Specify /EHsc */
81 #endif /* _MSC_VER (warnings) */
82 
83 /* *INDENT-OFF* */
84 /* clang-format off */
85 
169 /* *INDENT-ON* */
170 /* clang-format on */
171 
172 #include <stdarg.h>
173 #include <stddef.h>
174 #include <stdint.h>
175 #if !defined(NDEBUG) && !defined(assert)
176 #include <assert.h>
177 #endif /* NDEBUG */
178 
179 #if defined(_WIN32) || defined(_WIN64)
180 #include <windows.h>
181 #include <winnt.h>
182 #ifndef __mode_t_defined
183 typedef unsigned short mdbx_mode_t;
184 #else
185 typedef mode_t mdbx_mode_t;
186 #endif /* __mode_t_defined */
187 typedef HANDLE mdbx_filehandle_t;
188 typedef DWORD mdbx_pid_t;
189 typedef DWORD mdbx_tid_t;
190 #else /* Windows */
191 #include <errno.h> /* for error codes */
192 #include <pthread.h> /* for pthread_t */
193 #include <sys/types.h> /* for pid_t */
194 #include <sys/uio.h> /* for struct iovec */
195 #define HAVE_STRUCT_IOVEC 1
196 typedef int mdbx_filehandle_t;
197 typedef pid_t mdbx_pid_t;
198 typedef pthread_t mdbx_tid_t;
199 typedef mode_t mdbx_mode_t;
200 #endif /* !Windows */
201 
202 #ifdef _MSC_VER
203 #pragma warning(pop)
204 #endif
205 
210 /*----------------------------------------------------------------------------*/
211 
212 #ifndef __has_attribute
213 #define __has_attribute(x) (0)
214 #endif /* __has_attribute */
215 
216 #ifndef __has_cpp_attribute
217 #define __has_cpp_attribute(x) 0
218 #endif /* __has_cpp_attribute */
219 
220 #ifndef __has_feature
221 #define __has_feature(x) (0)
222 #endif /* __has_feature */
223 
224 #ifndef __has_extension
225 #define __has_extension(x) (0)
226 #endif /* __has_extension */
227 
228 #ifndef __has_builtin
229 #define __has_builtin(x) (0)
230 #endif /* __has_builtin */
231 
237 #if (defined(__GNUC__) || __has_attribute(__pure__)) && \
238  (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
239  || !defined(__cplusplus) || !__has_feature(cxx_exceptions))
240 #define MDBX_PURE_FUNCTION __attribute__((__pure__))
241 #elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
242 #define MDBX_PURE_FUNCTION
243 #elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure) && \
244  (!defined(__clang__) || !__has_feature(cxx_exceptions))
245 #define MDBX_PURE_FUNCTION [[gnu::pure]]
246 #else
247 #define MDBX_PURE_FUNCTION
248 #endif /* MDBX_PURE_FUNCTION */
249 
252 #if defined(__GNUC__) || \
253  (__has_attribute(__pure__) && __has_attribute(__nothrow__))
254 #define MDBX_NOTHROW_PURE_FUNCTION __attribute__((__pure__, __nothrow__))
255 #elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
256 #if __has_cpp_attribute(pure)
257 #define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
258 #else
259 #define MDBX_NOTHROW_PURE_FUNCTION
260 #endif
261 #elif defined(__cplusplus) && __has_cpp_attribute(gnu::pure)
262 #if __has_cpp_attribute(gnu::nothrow)
263 #define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure, gnu::nothrow]]
264 #else
265 #define MDBX_NOTHROW_PURE_FUNCTION [[gnu::pure]]
266 #endif
267 #elif defined(__cplusplus) && __has_cpp_attribute(pure)
268 #define MDBX_NOTHROW_PURE_FUNCTION [[pure]]
269 #else
270 #define MDBX_NOTHROW_PURE_FUNCTION
271 #endif /* MDBX_NOTHROW_PURE_FUNCTION */
272 
282 #if (defined(__GNUC__) || __has_attribute(__pure__)) && \
283  (!defined(__clang__) /* https://bugs.llvm.org/show_bug.cgi?id=43275 */ \
284  || !defined(__cplusplus) || !__has_feature(cxx_exceptions))
285 #define MDBX_CONST_FUNCTION __attribute__((__const__))
286 #elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
287 #define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
288 #elif defined(__cplusplus) && __has_cpp_attribute(gnu::const) && \
289  (!defined(__clang__) || !__has_feature(cxx_exceptions))
290 #define MDBX_CONST_FUNCTION [[gnu::const]]
291 #else
292 #define MDBX_CONST_FUNCTION MDBX_PURE_FUNCTION
293 #endif /* MDBX_CONST_FUNCTION */
294 
297 #if defined(__GNUC__) || \
298  (__has_attribute(__const__) && __has_attribute(__nothrow__))
299 #define MDBX_NOTHROW_CONST_FUNCTION __attribute__((__const__, __nothrow__))
300 #elif defined(_MSC_VER) && !defined(__clang__) && _MSC_VER >= 1920
301 #define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
302 #elif defined(__cplusplus) && __has_cpp_attribute(gnu::const)
303 #if __has_cpp_attribute(gnu::nothrow)
304 #define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const, gnu::nothrow]]
305 #else
306 #define MDBX_NOTHROW_PURE_FUNCTION [[gnu::const]]
307 #endif
308 #elif defined(__cplusplus) && __has_cpp_attribute(const)
309 #define MDBX_NOTHROW_CONST_FUNCTION [[const]]
310 #else
311 #define MDBX_NOTHROW_CONST_FUNCTION MDBX_NOTHROW_PURE_FUNCTION
312 #endif /* MDBX_NOTHROW_CONST_FUNCTION */
313 
314 #ifndef MDBX_DEPRECATED /* may be predefined to avoid warnings "deprecated" */
315 #ifdef __deprecated
316 #define MDBX_DEPRECATED __deprecated
317 #elif defined(__GNUC__) || __has_attribute(__deprecated__)
318 #define MDBX_DEPRECATED __attribute__((__deprecated__))
319 #elif defined(_MSC_VER)
320 #define MDBX_DEPRECATED __declspec(deprecated)
321 #else
322 #define MDBX_DEPRECATED
323 #endif
324 #endif /* MDBX_DEPRECATED */
325 
326 #ifndef __dll_export
327 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
328  defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
329 #if defined(__GNUC__) || __has_attribute(__dllexport__)
330 #define __dll_export __attribute__((__dllexport__))
331 #elif defined(_MSC_VER)
332 #define __dll_export __declspec(dllexport)
333 #else
334 #define __dll_export
335 #endif
336 #elif defined(__GNUC__) || __has_attribute(__visibility__)
337 #define __dll_export __attribute__((__visibility__("default")))
338 #else
339 #define __dll_export
340 #endif
341 #endif /* __dll_export */
342 
343 #ifndef __dll_import
344 #if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || \
345  defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
346 #if defined(__GNUC__) || __has_attribute(__dllimport__)
347 #define __dll_import __attribute__((__dllimport__))
348 #elif defined(_MSC_VER)
349 #define __dll_import __declspec(dllimport)
350 #else
351 #define __dll_import
352 #endif
353 #else
354 #define __dll_import
355 #endif
356 #endif /* __dll_import */
357 
361 #if defined(LIBMDBX_INTERNALS) && !defined(LIBMDBX_NO_EXPORTS_LEGACY_API)
362 #define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) \
363  /* proto of exported which uses common impl */ LIBMDBX_API TYPE NAME ARGS; \
364  /* definition of common impl */ static __inline TYPE __inline_##NAME ARGS
365 #else
366 #define LIBMDBX_INLINE_API(TYPE, NAME, ARGS) static __inline TYPE NAME ARGS
367 #endif /* LIBMDBX_INLINE_API */
368 
370 #ifndef MDBX_STRINGIFY
371 #define MDBX_STRINGIFY_HELPER(x) #x
372 #define MDBX_STRINGIFY(x) MDBX_STRINGIFY_HELPER(x)
373 #endif /* MDBX_STRINGIFY */
374 
375 /*----------------------------------------------------------------------------*/
376 
377 #ifndef __cplusplus
378 #ifndef bool
379 #define bool _Bool
380 #endif
381 #ifndef true
382 #define true (1)
383 #endif
384 #ifndef false
385 #define false (0)
386 #endif
387 #endif /* bool without __cplusplus */
388 
389 #if !defined(DOXYGEN) && (!defined(__cpp_noexcept_function_type) || \
390  __cpp_noexcept_function_type < 201510L)
391 #define MDBX_CXX17_NOEXCEPT
392 #else
393 #define MDBX_CXX17_NOEXCEPT noexcept
394 #endif /* MDBX_CXX17_NOEXCEPT */
395 
396 /* Workaround for old compilers without properly support for constexpr. */
397 #if !defined(__cplusplus)
398 #define MDBX_CXX01_CONSTEXPR __inline
399 #define MDBX_CXX01_CONSTEXPR_VAR const
400 #elif !defined(DOXYGEN) && \
401  ((__cplusplus < 201103L && defined(__cpp_constexpr) && \
402  __cpp_constexpr < 200704L) || \
403  (defined(__LCC__) && __LCC__ < 124) || \
404  (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
405  !defined(__clang__) && !defined(__LCC__)) || \
406  (defined(_MSC_VER) && _MSC_VER < 1910) || \
407  (defined(__clang__) && __clang_major__ < 4))
408 #define MDBX_CXX01_CONSTEXPR inline
409 #define MDBX_CXX01_CONSTEXPR_VAR const
410 #else
411 #define MDBX_CXX01_CONSTEXPR constexpr
412 #define MDBX_CXX01_CONSTEXPR_VAR constexpr
413 #endif /* MDBX_CXX01_CONSTEXPR */
414 
415 #if !defined(__cplusplus)
416 #define MDBX_CXX11_CONSTEXPR __inline
417 #define MDBX_CXX11_CONSTEXPR_VAR const
418 #elif !defined(DOXYGEN) && \
419  (!defined(__cpp_constexpr) || __cpp_constexpr < 201304L || \
420  (defined(__LCC__) && __LCC__ < 124) || \
421  (defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__) && \
422  !defined(__LCC__)) || \
423  (defined(_MSC_VER) && _MSC_VER < 1910) || \
424  (defined(__clang__) && __clang_major__ < 5))
425 #define MDBX_CXX11_CONSTEXPR inline
426 #define MDBX_CXX11_CONSTEXPR_VAR const
427 #else
428 #define MDBX_CXX11_CONSTEXPR constexpr
429 #define MDBX_CXX11_CONSTEXPR_VAR constexpr
430 #endif /* MDBX_CXX11_CONSTEXPR */
431 
432 #if !defined(__cplusplus)
433 #define MDBX_CXX14_CONSTEXPR __inline
434 #define MDBX_CXX14_CONSTEXPR_VAR const
435 #elif defined(DOXYGEN) || \
436  defined(__cpp_constexpr) && __cpp_constexpr >= 201304L && \
437  ((defined(_MSC_VER) && _MSC_VER >= 1910) || \
438  (defined(__clang__) && __clang_major__ > 4) || \
439  (defined(__GNUC__) && __GNUC__ > 6) || \
440  (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
441 #define MDBX_CXX14_CONSTEXPR constexpr
442 #define MDBX_CXX14_CONSTEXPR_VAR constexpr
443 #else
444 #define MDBX_CXX14_CONSTEXPR inline
445 #define MDBX_CXX14_CONSTEXPR_VAR const
446 #endif /* MDBX_CXX14_CONSTEXPR */
447 
448 #if defined(__noreturn)
449 #define MDBX_NORETURN __noreturn
450 #elif defined(_Noreturn)
451 #define MDBX_NORETURN _Noreturn
452 #elif defined(__GNUC__) || __has_attribute(__noreturn__)
453 #define MDBX_NORETURN __attribute__((__noreturn__))
454 #elif defined(_MSC_VER) && !defined(__clang__)
455 #define MDBX_NORETURN __declspec(noreturn)
456 #else
457 #define MDBX_NORETURN
458 #endif /* MDBX_NORETURN */
459 
460 #ifndef MDBX_PRINTF_ARGS
461 #if defined(__GNUC__) || __has_attribute(__format__)
462 #if defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__)
463 #define MDBX_PRINTF_ARGS(format_index, first_arg) \
464  __attribute__((__format__(__gnu_printf__, format_index, first_arg)))
465 #else
466 #define MDBX_PRINTF_ARGS(format_index, first_arg) \
467  __attribute__((__format__(__printf__, format_index, first_arg)))
468 #endif /* MinGW */
469 #else
470 #define MDBX_PRINTF_ARGS(format_index, first_arg)
471 #endif
472 #endif /* MDBX_PRINTF_ARGS */
473 
474 #if defined(DOXYGEN) || \
475  (defined(__cplusplus) && __cplusplus >= 201603 && \
476  __has_cpp_attribute(maybe_unused) && \
477  __has_cpp_attribute(maybe_unused) >= 201603) || \
478  (!defined(__cplusplus) && defined(__STDC_VERSION__) && \
479  __STDC_VERSION__ > 202005L)
480 #define MDBX_MAYBE_UNUSED [[maybe_unused]]
481 #elif defined(__GNUC__) || __has_attribute(__unused__)
482 #define MDBX_MAYBE_UNUSED __attribute__((__unused__))
483 #else
484 #define MDBX_MAYBE_UNUSED
485 #endif /* MDBX_MAYBE_UNUSED */
486 
487 #if __has_attribute(no_sanitize)
488 #define MDBX_NOSANITIZE_ENUM __attribute((__no_sanitize__("enum")))
489 #else
490 #define MDBX_NOSANITIZE_ENUM
491 #endif /* MDBX_NOSANITIZE_ENUM */
492 
493 /* Oh, below are some songs and dances since:
494  * - C++ requires explicit definition of the necessary operators.
495  * - the proper implementation of DEFINE_ENUM_FLAG_OPERATORS for C++ required
496  * the constexpr feature which is broken in most old compilers;
497  * - DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK. */
498 #ifndef DEFINE_ENUM_FLAG_OPERATORS
499 
500 #ifdef __cplusplus
501 #if !defined(__cpp_constexpr) || __cpp_constexpr < 200704L || \
502  (defined(__LCC__) && __LCC__ < 124) || \
503  (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407) && \
504  !defined(__clang__) && !defined(__LCC__)) || \
505  (defined(_MSC_VER) && _MSC_VER < 1910) || \
506  (defined(__clang__) && __clang_major__ < 4)
507 /* The constexpr feature is not available or (may be) broken */
508 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
509 #else
510 /* C always allows these operators for enums */
511 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
512 #endif /* __cpp_constexpr */
513 
516 #define DEFINE_ENUM_FLAG_OPERATORS(ENUM) \
517  extern "C++" { \
518  MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator|(ENUM a, ENUM b) { \
519  return ENUM(unsigned(a) | unsigned(b)); \
520  } \
521  MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator|=(ENUM &a, \
522  ENUM b) { \
523  return a = a | b; \
524  } \
525  MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, ENUM b) { \
526  return ENUM(unsigned(a) & unsigned(b)); \
527  } \
528  MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(ENUM a, \
529  unsigned b) { \
530  return ENUM(unsigned(a) & b); \
531  } \
532  MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator&(unsigned a, \
533  ENUM b) { \
534  return ENUM(a & unsigned(b)); \
535  } \
536  MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, \
537  ENUM b) { \
538  return a = a & b; \
539  } \
540  MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator&=(ENUM &a, \
541  unsigned b) { \
542  return a = a & b; \
543  } \
544  MDBX_CXX01_CONSTEXPR unsigned operator~(ENUM a) { return ~unsigned(a); } \
545  MDBX_NOSANITIZE_ENUM MDBX_CXX01_CONSTEXPR ENUM operator^(ENUM a, ENUM b) { \
546  return ENUM(unsigned(a) ^ unsigned(b)); \
547  } \
548  MDBX_NOSANITIZE_ENUM MDBX_CXX14_CONSTEXPR ENUM &operator^=(ENUM &a, \
549  ENUM b) { \
550  return a = a ^ b; \
551  } \
552  }
553 #else /* __cplusplus */
554 /* nope for C since it always allows these operators for enums */
555 #define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
556 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
557 #endif /* !__cplusplus */
558 
559 #elif !defined(CONSTEXPR_ENUM_FLAGS_OPERATIONS)
560 
561 #ifdef __cplusplus
562 /* DEFINE_ENUM_FLAG_OPERATORS may be defined broken as in the Windows SDK */
563 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 0
564 #else
565 /* C always allows these operators for enums */
566 #define CONSTEXPR_ENUM_FLAGS_OPERATIONS 1
567 #endif
568 
569 #endif /* DEFINE_ENUM_FLAG_OPERATORS */
570 
573 /*----------------------------------------------------------------------------*/
574 
578 #ifdef __cplusplus
579 extern "C" {
580 #endif
581 
582 /* MDBX version 0.11.x */
583 #define MDBX_VERSION_MAJOR 0
584 #define MDBX_VERSION_MINOR 11
585 
586 #ifndef LIBMDBX_API
587 #if defined(LIBMDBX_EXPORTS)
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)
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  uint8_t major;
615  uint8_t minor;
616  uint16_t release;
617  uint32_t revision;
618  struct {
619  const char *datetime;
620  const char *tree;
621  const char *commit;
622  const char *describe;
623  } git;
624  const char *sourcery;
625 } mdbx_version;
626 
631  const char *datetime;
632  const char *target;
633  const char *options;
634  const char *compiler;
635  const char *flags;
636 } mdbx_build;
637 
638 #if (defined(_WIN32) || defined(_WIN64)) && !MDBX_BUILD_SHARED_LIBRARY
639 /* MDBX internally uses global and thread local storage destructors to
640  * automatically (de)initialization, releasing reader lock table slots
641  * and so on.
642  *
643  * If MDBX builded as a DLL this is done out-of-the-box by DllEntry() function,
644  * which called automatically by Windows core with passing corresponding reason
645  * argument.
646  *
647  * Otherwise, if MDBX was builded not as a DLL, some black magic
648  * may be required depending of Windows version:
649  *
650  * - Modern Windows versions, including Windows Vista and later, provides
651  * support for "TLS Directory" (e.g .CRT$XL[A-Z] sections in executable
652  * or dll file). In this case, MDBX capable of doing all automatically,
653  * therefore you DON'T NEED to call mdbx_module_handler()
654  * so the MDBX_MANUAL_MODULE_HANDLER defined as 0.
655  *
656  * - Obsolete versions of Windows, prior to Windows Vista, REQUIRES calling
657  * mdbx_module_handler() manually from corresponding DllMain() or WinMain()
658  * of your DLL or application,
659  * so the MDBX_MANUAL_MODULE_HANDLER defined as 1.
660  *
661  * Therefore, building MDBX as a DLL is recommended for all version of Windows.
662  * So, if you doubt, just build MDBX as the separate DLL and don't care about
663  * the MDBX_MANUAL_MODULE_HANDLER. */
664 
665 #ifndef _WIN32_WINNT
666 #error Non-dll build libmdbx requires target Windows version \
667  to be explicitly defined via _WIN32_WINNT for properly \
668  handling thread local storage destructors.
669 #endif /* _WIN32_WINNT */
670 
671 #if _WIN32_WINNT >= 0x0600 /* Windows Vista */
672 /* As described above mdbx_module_handler() is NOT needed for Windows Vista
673  * and later. */
674 #define MDBX_MANUAL_MODULE_HANDLER 0
675 #else
676 /* As described above mdbx_module_handler() IS REQUIRED for Windows versions
677  * prior to Windows Vista. */
678 #define MDBX_MANUAL_MODULE_HANDLER 1
679 void LIBMDBX_API NTAPI mdbx_module_handler(PVOID module, DWORD reason,
680  PVOID reserved);
681 #endif
682 
683 #endif /* Windows && !DLL && MDBX_MANUAL_MODULE_HANDLER */
684 
685 /* OPACITY STRUCTURES *********************************************************/
686 
691 #ifndef __cplusplus
692 typedef struct MDBX_env MDBX_env;
693 #else
694 struct MDBX_env;
695 #endif
696 
702 #ifndef __cplusplus
703 typedef struct MDBX_txn MDBX_txn;
704 #else
705 struct MDBX_txn;
706 #endif
707 
715 typedef uint32_t MDBX_dbi;
716 
721 #ifndef __cplusplus
722 typedef struct MDBX_cursor MDBX_cursor;
723 #else
724 struct MDBX_cursor;
725 #endif
726 
741 #ifndef HAVE_STRUCT_IOVEC
742 struct iovec {
743  void *iov_base;
744  size_t iov_len;
745 };
746 #define HAVE_STRUCT_IOVEC
747 #endif /* HAVE_STRUCT_IOVEC */
748 
749 #if defined(__sun) || defined(__SVR4) || defined(__svr4__)
750 /* The `iov_len` is signed on Sun/Solaris.
751  * So define custom MDBX_val to avoid a lot of warnings. */
752 struct MDBX_val {
753  void *iov_base;
754  size_t iov_len;
755 };
756 #ifndef __cplusplus
757 typedef struct MDBX_val MDBX_val;
758 #endif
759 #else /* SunOS */
760 typedef struct iovec MDBX_val;
761 #endif /* ! SunOS */
762 
765  MDBX_MAX_DBI = UINT32_C(32765),
766 
768  MDBX_MAXDATASIZE = UINT32_C(0x7fff0000),
769 
772 
775 };
776 
777 /* THE FILES *******************************************************************
778  * At the file system level, the environment corresponds to a pair of files. */
779 
781 #define MDBX_LOCKNAME "/mdbx.lck"
782 
783 #define MDBX_DATANAME "/mdbx.dat"
784 
786 #define MDBX_LOCK_SUFFIX "-lck"
787 
788 /* DEBUG & LOGGING ************************************************************/
789 
802 
808 
814 
820 
825 
830 
835 
840 
841 #ifdef ENABLE_UBSAN
842  MDBX_LOG_MAX = 7 /* avoid UBSAN false-positive trap by a tests */,
843 #endif /* ENABLE_UBSAN */
844 
847 };
848 #ifndef __cplusplus
850 #endif
851 
859 
864 
868 
872 
876 
879 
882 
887 
888 #ifdef ENABLE_UBSAN
889  MDBX_DBG_MAX = ((unsigned)MDBX_LOG_MAX) << 16 |
890  127 /* avoid UBSAN false-positive trap by a tests */,
891 #endif /* ENABLE_UBSAN */
892 
895 };
896 #ifndef __cplusplus
898 #else
900 #endif
901 
908 typedef void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function,
909  int line, const char *fmt,
910  va_list args) MDBX_CXX17_NOEXCEPT;
911 
913 #define MDBX_LOGGER_DONTCHANGE ((MDBX_debug_func *)(intptr_t)-1)
914 
919  MDBX_debug_flags_t debug_flags,
920  MDBX_debug_func *logger);
921 
928 typedef void MDBX_assert_func(const MDBX_env *env, const char *msg,
929  const char *function,
930  unsigned line) MDBX_CXX17_NOEXCEPT;
931 
942 
952 LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
953  const size_t bufsize);
954 
956 LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
957 
966 
983  MDBX_NOSUBDIR = UINT32_C(0x4000),
984 
1001  MDBX_RDONLY = UINT32_C(0x20000),
1002 
1031  MDBX_EXCLUSIVE = UINT32_C(0x400000),
1032 
1046  MDBX_ACCEDE = UINT32_C(0x40000000),
1047 
1077  MDBX_WRITEMAP = UINT32_C(0x80000),
1078 
1100  MDBX_NOTLS = UINT32_C(0x200000),
1101 
1121  MDBX_NORDAHEAD = UINT32_C(0x800000),
1122 
1144  MDBX_NOMEMINIT = UINT32_C(0x1000000),
1145 
1156  MDBX_COALESCE = UINT32_C(0x2000000),
1157 
1180  MDBX_LIFORECLAIM = UINT32_C(0x4000000),
1181 
1183  MDBX_PAGEPERTURB = UINT32_C(0x8000000),
1184 
1185  /* SYNC MODES****************************************************************/
1238 
1255  MDBX_NOMETASYNC = UINT32_C(0x40000),
1256 
1306  MDBX_SAFE_NOSYNC = UINT32_C(0x10000),
1307 
1314 
1356  MDBX_UTTERLY_NOSYNC = MDBX_SAFE_NOSYNC | UINT32_C(0x100000),
1357 
1359 };
1360 #ifndef __cplusplus
1361 
1363 #else
1365 #endif
1366 
1377 
1383 
1390 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
1392 #else
1393  MDBX_TXN_RDONLY_PREPARE = uint32_t(MDBX_RDONLY) | uint32_t(MDBX_NOMEMINIT),
1394 #endif
1395 
1397  MDBX_TXN_TRY = UINT32_C(0x10000000),
1398 
1402 
1406 };
1407 #ifndef __cplusplus
1409 #else
1411 #endif
1412 
1420 
1422  MDBX_REVERSEKEY = UINT32_C(0x02),
1423 
1425  MDBX_DUPSORT = UINT32_C(0x04),
1426 
1432  MDBX_INTEGERKEY = UINT32_C(0x08),
1433 
1436  MDBX_DUPFIXED = UINT32_C(0x10),
1437 
1441  MDBX_INTEGERDUP = UINT32_C(0x20),
1442 
1444  MDBX_REVERSEDUP = UINT32_C(0x40),
1445 
1447  MDBX_CREATE = UINT32_C(0x40000),
1448 
1460 };
1461 #ifndef __cplusplus
1462 
1464 #else
1466 #endif
1467 
1475 
1477  MDBX_NOOVERWRITE = UINT32_C(0x10),
1478 
1482  MDBX_NODUPDATA = UINT32_C(0x20),
1483 
1488  MDBX_CURRENT = UINT32_C(0x40),
1489 
1493  MDBX_ALLDUPS = UINT32_C(0x80),
1494 
1497  MDBX_RESERVE = UINT32_C(0x10000),
1498 
1501  MDBX_APPEND = UINT32_C(0x20000),
1502 
1506  MDBX_APPENDDUP = UINT32_C(0x40000),
1507 
1510  MDBX_MULTIPLE = UINT32_C(0x80000)
1511 };
1512 #ifndef __cplusplus
1513 
1515 #else
1517 #endif
1518 
1524 
1528 
1531 };
1532 #ifndef __cplusplus
1533 
1535 #else
1537 #endif
1538 
1546 
1549 
1552 
1556 
1559 
1564 
1567 
1570 
1573 
1576 
1581 
1584 
1587 
1590 
1593 
1596 
1599 
1602 
1606 
1620 
1634 };
1635 #ifndef __cplusplus
1636 
1638 #endif
1639 
1648 
1651 
1654 
1656  MDBX_KEYEXIST = -30799,
1657 
1660 
1662  MDBX_NOTFOUND = -30798,
1663 
1666 
1668  MDBX_CORRUPTED = -30796,
1669 
1672  MDBX_PANIC = -30795,
1673 
1676 
1678  MDBX_INVALID = -30793,
1679 
1681  MDBX_MAP_FULL = -30792,
1682 
1684  MDBX_DBS_FULL = -30791,
1685 
1688 
1690  MDBX_TXN_FULL = -30788,
1691 
1695 
1697  MDBX_PAGE_FULL = -30786,
1698 
1707 
1717 
1720  MDBX_BAD_RSLOT = -30783,
1721 
1724  MDBX_BAD_TXN = -30782,
1725 
1729 
1732  MDBX_BAD_DBI = -30780,
1733 
1735  MDBX_PROBLEM = -30779,
1736 
1739 
1742  MDBX_BUSY = -30778,
1743 
1746 
1748  MDBX_EMULTIVAL = -30421,
1749 
1753  MDBX_EBADSIGN = -30420,
1754 
1758 
1761 
1764  MDBX_TOO_LARGE = -30417,
1765 
1769 
1772 
1773  /* The last of MDBX-added error codes */
1775 
1776 #if defined(_WIN32) || defined(_WIN64)
1777  MDBX_ENODATA = ERROR_HANDLE_EOF,
1778  MDBX_EINVAL = ERROR_INVALID_PARAMETER,
1779  MDBX_EACCESS = ERROR_ACCESS_DENIED,
1780  MDBX_ENOMEM = ERROR_OUTOFMEMORY,
1781  MDBX_EROFS = ERROR_FILE_READ_ONLY,
1782  MDBX_ENOSYS = ERROR_NOT_SUPPORTED,
1783  MDBX_EIO = ERROR_WRITE_FAULT,
1784  MDBX_EPERM = ERROR_INVALID_FUNCTION,
1785  MDBX_EINTR = ERROR_CANCELLED,
1786  MDBX_ENOFILE = ERROR_FILE_NOT_FOUND,
1787  MDBX_EREMOTE = ERROR_REMOTE_STORAGE_MEDIA_ERROR
1788 #else /* Windows */
1789 #ifdef ENODATA
1790  MDBX_ENODATA = ENODATA,
1791 #else
1792  MDBX_ENODATA = 9919 /* for compatibility with LLVM's C++ libraries/headers */,
1793 #endif /* ENODATA */
1794  MDBX_EINVAL = EINVAL,
1795  MDBX_EACCESS = EACCES,
1796  MDBX_ENOMEM = ENOMEM,
1797  MDBX_EROFS = EROFS,
1798  MDBX_ENOSYS = ENOSYS,
1799  MDBX_EIO = EIO,
1800  MDBX_EPERM = EPERM,
1801  MDBX_EINTR = EINTR,
1802  MDBX_ENOFILE = ENOENT,
1803  MDBX_EREMOTE = ENOTBLK
1804 #endif /* !Windows */
1805 };
1806 #ifndef __cplusplus
1807 
1809 #endif
1810 
1815 MDBX_DEPRECATED static __inline int MDBX_MAP_RESIZED_is_deprecated() {
1817 }
1818 #define MDBX_MAP_RESIZED MDBX_MAP_RESIZED_is_deprecated()
1819 
1838 LIBMDBX_API const char *mdbx_strerror(int errnum);
1839 
1864 LIBMDBX_API const char *mdbx_strerror_r(int errnum, char *buf, size_t buflen);
1866 
1867 #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
1868 
1872 LIBMDBX_API const char *mdbx_strerror_ANSI2OEM(int errnum);
1873 
1878 LIBMDBX_API const char *mdbx_strerror_r_ANSI2OEM(int errnum, char *buf,
1879  size_t buflen);
1880 #endif /* Bit of Windows' madness */
1881 
1897 
1909 
1925 
1931 
1937 
1956 
1969 
1983 
1997 
2001 
2017 
2033 
2056 
2067 };
2068 #ifndef __cplusplus
2069 
2071 #endif
2072 
2083 LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option,
2084  uint64_t value);
2085 
2097  const MDBX_option_t option,
2098  uint64_t *pvalue);
2099 
2171 LIBMDBX_API int mdbx_env_open(MDBX_env *env, const char *pathname,
2172  MDBX_env_flags_t flags, mdbx_mode_t mode);
2173 
2191 };
2192 #ifndef __cplusplus
2193 
2195 #endif
2196 
2214 LIBMDBX_API int mdbx_env_delete(const char *pathname,
2215  MDBX_env_delete_mode_t mode);
2216 
2248 LIBMDBX_API int mdbx_env_copy(MDBX_env *env, const char *dest,
2249  MDBX_copy_flags_t flags);
2250 
2275  MDBX_copy_flags_t flags);
2276 
2280 struct MDBX_stat {
2281  uint32_t ms_psize;
2283  uint32_t ms_depth;
2284  uint64_t ms_branch_pages;
2285  uint64_t ms_leaf_pages;
2287  uint64_t ms_entries;
2288  uint64_t ms_mod_txnid;
2289 };
2290 #ifndef __cplusplus
2291 
2292 typedef struct MDBX_stat MDBX_stat;
2293 #endif
2294 
2314 LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn,
2315  MDBX_stat *stat, size_t bytes);
2316 
2320 MDBX_DEPRECATED inline int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat,
2321  size_t bytes) {
2322  return mdbx_env_stat_ex(env, NULL, stat, bytes);
2323 }
2324 
2329  struct {
2330  uint64_t lower;
2331  uint64_t upper;
2332  uint64_t current;
2333  uint64_t shrink;
2334  uint64_t grow;
2335  } mi_geo;
2336  uint64_t mi_mapsize;
2337  uint64_t mi_last_pgno;
2338  uint64_t mi_recent_txnid;
2345  uint32_t mi_maxreaders;
2346  uint32_t mi_numreaders;
2347  uint32_t mi_dxb_pagesize;
2348  uint32_t mi_sys_pagesize;
2358  struct {
2359  struct {
2360  uint64_t x, y;
2361  } current, meta0, meta1, meta2;
2362  } mi_bootid;
2363 
2378  uint32_t mi_mode;
2379 
2385  struct {
2386  uint64_t newly;
2387  uint64_t cow;
2388  uint64_t clone;
2390  uint64_t split;
2391  uint64_t merge;
2392  uint64_t spill;
2393  uint64_t unspill;
2394  uint64_t wops;
2396  } mi_pgop_stat;
2397 };
2398 #ifndef __cplusplus
2399 
2400 typedef struct MDBX_envinfo MDBX_envinfo;
2401 #endif
2402 
2422 LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn,
2423  MDBX_envinfo *info, size_t bytes);
2428  size_t bytes) {
2429  return mdbx_env_info_ex(env, NULL, info, bytes);
2430 }
2431 
2467 LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock);
2468 
2472 inline int mdbx_env_sync(MDBX_env * env) {
2473  return mdbx_env_sync_ex(env, true, false);
2474 }
2475 
2479 inline int mdbx_env_sync_poll(MDBX_env * env) {
2480  return mdbx_env_sync_ex(env, false, true);
2481 }
2482 
2506 inline int mdbx_env_set_syncbytes(MDBX_env * env, size_t threshold) {
2507  return mdbx_env_set_option(env, MDBX_opt_sync_bytes, threshold);
2508 }
2509 
2524 inline int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold) {
2525  int rc = MDBX_EINVAL;
2526  if (threshold) {
2527  uint64_t proxy = 0;
2528  rc = mdbx_env_get_option(env, MDBX_opt_sync_bytes, &proxy);
2529 #ifdef assert
2530  assert(proxy <= SIZE_MAX);
2531 #endif /* assert */
2532  *threshold = (size_t)proxy;
2533  }
2534  return rc;
2535 }
2536 
2567 inline int mdbx_env_set_syncperiod(MDBX_env * env, unsigned seconds_16dot16) {
2568  return mdbx_env_set_option(env, MDBX_opt_sync_period, seconds_16dot16);
2569 }
2570 
2587 inline int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16) {
2588  int rc = MDBX_EINVAL;
2589  if (period_seconds_16dot16) {
2590  uint64_t proxy = 0;
2591  rc = mdbx_env_get_option(env, MDBX_opt_sync_period, &proxy);
2592 #ifdef assert
2593  assert(proxy <= UINT32_MAX);
2594 #endif /* assert */
2595  *period_seconds_16dot16 = (unsigned)proxy;
2596  }
2597  return rc;
2598 }
2599 
2638 LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync);
2639 
2643 inline int mdbx_env_close(MDBX_env * env) {
2644  return mdbx_env_close_ex(env, false);
2645 }
2646 
2668  bool onoff);
2669 
2680 LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags);
2681 
2693 LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest);
2694 
2708 
2903 LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower,
2904  intptr_t size_now, intptr_t size_upper,
2905  intptr_t growth_step,
2906  intptr_t shrink_threshold,
2907  intptr_t pagesize);
2908 
2911 MDBX_DEPRECATED inline int mdbx_env_set_mapsize(MDBX_env * env, size_t size) {
2912  return mdbx_env_set_geometry(env, size, size, size, -1, -1, -1);
2913 }
2914 
2930 LIBMDBX_API int mdbx_is_readahead_reasonable(size_t volume,
2931  intptr_t redundancy);
2932 
2936  return MDBX_MIN_PAGESIZE;
2937 }
2938 
2942  return MDBX_MAX_PAGESIZE;
2943 }
2944 
2949 mdbx_limits_dbsize_min(intptr_t pagesize);
2950 
2955 mdbx_limits_dbsize_max(intptr_t pagesize);
2956 
2962 mdbx_limits_keysize_max(intptr_t pagesize, MDBX_db_flags_t flags);
2963 
2969 mdbx_limits_valsize_max(intptr_t pagesize, MDBX_db_flags_t flags);
2970 
2975 mdbx_limits_txnsize_max(intptr_t pagesize);
2976 
3000 inline int mdbx_env_set_maxreaders(MDBX_env * env, unsigned readers) {
3001  return mdbx_env_set_option(env, MDBX_opt_max_readers, readers);
3002 }
3003 
3015 inline int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers) {
3016  int rc = MDBX_EINVAL;
3017  if (readers) {
3018  uint64_t proxy = 0;
3019  rc = mdbx_env_get_option(env, MDBX_opt_max_readers, &proxy);
3020  *readers = (unsigned)proxy;
3021  }
3022  return rc;
3023 }
3024 
3046 inline int mdbx_env_set_maxdbs(MDBX_env * env, MDBX_dbi dbs) {
3047  return mdbx_env_set_option(env, MDBX_opt_max_db, dbs);
3048 }
3049 
3060 inline int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs) {
3061  int rc = MDBX_EINVAL;
3062  if (dbs) {
3063  uint64_t proxy = 0;
3064  rc = mdbx_env_get_option(env, MDBX_opt_max_db, &proxy);
3065  *dbs = (MDBX_dbi)proxy;
3066  }
3067  return rc;
3068 }
3069 
3075 
3090 LIBMDBX_API int mdbx_get_sysraminfo(intptr_t *page_size, intptr_t *total_pages,
3091  intptr_t *avail_pages);
3092 
3104 
3116 
3121 mdbx_env_get_maxkeysize(const MDBX_env *env);
3122 
3132 LIBMDBX_API int mdbx_env_set_userctx(MDBX_env *env, void *ctx);
3133 
3143 mdbx_env_get_userctx(const MDBX_env *env);
3144 
3205  MDBX_txn_flags_t flags, MDBX_txn **txn,
3206  void *context);
3207 
3262 inline int mdbx_txn_begin(MDBX_env * env, MDBX_txn *parent, MDBX_txn_flags_t flags,
3263  MDBX_txn **txn) {
3264  return mdbx_txn_begin_ex(env, parent, flags, txn, NULL);
3265 }
3266 
3277 LIBMDBX_API int mdbx_txn_set_userctx(MDBX_txn *txn, void *ctx);
3278 
3290 mdbx_txn_get_userctx(const MDBX_txn *txn);
3291 
3298  uint64_t txn_id;
3299 
3304  uint64_t txn_reader_lag;
3305 
3308  uint64_t txn_space_used;
3309 
3312 
3316 
3324 
3331 
3338 };
3339 #ifndef __cplusplus
3340 
3341 typedef struct MDBX_txn_info MDBX_txn_info;
3342 #endif
3343 
3357 LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info,
3358  bool scan_rlt);
3359 
3365 mdbx_txn_env(const MDBX_txn *txn);
3366 
3377 
3390 mdbx_txn_id(const MDBX_txn *txn);
3391 
3398  uint32_t preparation;
3400  uint32_t gc;
3402  uint32_t audit;
3405  uint32_t write;
3408  uint32_t sync;
3410  uint32_t ending;
3412  uint32_t whole;
3413 };
3414 #ifndef __cplusplus
3415 
3417 #endif
3418 
3425 
3463 inline int mdbx_txn_commit(MDBX_txn * txn) {
3464  return mdbx_txn_commit_ex(txn, NULL);
3465 }
3466 
3501 
3514 
3548 
3570 
3581 struct MDBX_canary {
3582  uint64_t x, y, z, v;
3583 };
3584 #ifndef __cplusplus
3585 
3586 typedef struct MDBX_canary MDBX_canary;
3587 #endif
3588 
3607 LIBMDBX_API int mdbx_canary_put(MDBX_txn *txn, const MDBX_canary *canary);
3608 
3619 LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary);
3620 
3641 typedef int(MDBX_cmp_func)(const MDBX_val *a,
3642  const MDBX_val *b) MDBX_CXX17_NOEXCEPT;
3643 
3733 LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name,
3734  MDBX_db_flags_t flags, MDBX_dbi *dbi);
3735 
3752 mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags,
3753  MDBX_dbi *dbi, MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp);
3754 
3767 mdbx_key_from_jsonInteger(const int64_t json_integer);
3768 
3770 mdbx_key_from_double(const double ieee754_64bit);
3771 
3773 mdbx_key_from_ptrdouble(const double *const ieee754_64bit);
3774 
3776 mdbx_key_from_float(const float ieee754_32bit);
3777 
3779 mdbx_key_from_ptrfloat(const float *const ieee754_32bit);
3780 
3781 MDBX_NOTHROW_CONST_FUNCTION inline uint64_t mdbx_key_from_int64(const int64_t i64) {
3782  return UINT64_C(0x8000000000000000) + i64;
3783 }
3784 
3785 MDBX_NOTHROW_CONST_FUNCTION inline uint32_t mdbx_key_from_int32(const int32_t i32) {
3786  return UINT32_C(0x80000000) + i32;
3787 }
3797 
3800 
3803 
3806 
3825 LIBMDBX_API int mdbx_dbi_stat(MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat,
3826  size_t bytes);
3827 
3844  uint32_t *mask);
3845 
3858 };
3859 #ifndef __cplusplus
3860 
3862 #else
3864 #endif
3865 
3875 LIBMDBX_API int mdbx_dbi_flags_ex(MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags,
3876  unsigned *state);
3880 inline int mdbx_dbi_flags(MDBX_txn * txn, MDBX_dbi dbi, unsigned *flags) {
3881  unsigned state;
3882  return mdbx_dbi_flags_ex(txn, dbi, flags, &state);
3883 }
3884 
3908 
3920 LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del);
3921 
3951 LIBMDBX_API int mdbx_get(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key,
3952  MDBX_val *data);
3953 
3984 LIBMDBX_API int mdbx_get_ex(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
3985  MDBX_val *data, size_t *values_count);
3986 
4016  MDBX_val *key, MDBX_val *data);
4017 
4099 LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key,
4100  MDBX_val *data, MDBX_put_flags_t flags);
4101 
4145 LIBMDBX_API int mdbx_replace(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key,
4146  MDBX_val *new_data, MDBX_val *old_data,
4147  MDBX_put_flags_t flags);
4148 
4149 typedef int (*MDBX_preserve_func)(void *context, MDBX_val *target,
4150  const void *src, size_t bytes);
4152  const MDBX_val *key, MDBX_val *new_data,
4153  MDBX_val *old_data, MDBX_put_flags_t flags,
4154  MDBX_preserve_func preserver,
4155  void *preserver_context);
4156 
4182 LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key,
4183  const MDBX_val *data);
4184 
4208 
4218 LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx);
4219 
4230 mdbx_cursor_get_userctx(const MDBX_cursor *cursor);
4231 
4258  MDBX_dbi dbi);
4259 
4291  MDBX_cursor **cursor);
4292 
4308 
4333 
4339 mdbx_cursor_txn(const MDBX_cursor *cursor);
4340 
4346 
4357 LIBMDBX_API int mdbx_cursor_copy(const MDBX_cursor *src, MDBX_cursor *dest);
4358 
4381  MDBX_val *data, MDBX_cursor_op op);
4382 
4416 LIBMDBX_API int mdbx_cursor_get_batch(MDBX_cursor *cursor, size_t *count,
4417  MDBX_val *pairs, size_t limit,
4418  MDBX_cursor_op op);
4419 
4500 LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key,
4501  MDBX_val *data, MDBX_put_flags_t flags);
4502 
4534 
4550 LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount);
4551 
4565 mdbx_cursor_eof(const MDBX_cursor *cursor);
4566 
4579 mdbx_cursor_on_first(const MDBX_cursor *cursor);
4580 
4593 mdbx_cursor_on_last(const MDBX_cursor *cursor);
4594 
4640  const MDBX_cursor *last,
4641  ptrdiff_t *distance_items);
4642 
4663 LIBMDBX_API int mdbx_estimate_move(const MDBX_cursor *cursor, MDBX_val *key,
4664  MDBX_val *data, MDBX_cursor_op move_op,
4665  ptrdiff_t *distance_items);
4666 
4692  MDBX_val *begin_key, MDBX_val *begin_data,
4693  MDBX_val *end_key, MDBX_val *end_data,
4694  ptrdiff_t *distance_items);
4695 
4698 #define MDBX_EPSILON ((MDBX_val *)((ptrdiff_t)-1))
4699 
4734  const void *ptr);
4735 
4757 LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result,
4758  uint64_t increment);
4759 
4776  MDBX_dbi dbi,
4777  const MDBX_val *a,
4778  const MDBX_val *b);
4779 
4784 
4801  MDBX_dbi dbi,
4802  const MDBX_val *a,
4803  const MDBX_val *b);
4804 
4809 
4835 typedef int(MDBX_reader_list_func)(void *ctx, int num, int slot, mdbx_pid_t pid,
4836  mdbx_tid_t thread, uint64_t txnid,
4837  uint64_t lag, size_t bytes_used,
4838  size_t bytes_retained) MDBX_CXX17_NOEXCEPT;
4839 
4851 LIBMDBX_API int mdbx_reader_list(const MDBX_env *env,
4852  MDBX_reader_list_func *func, void *ctx);
4853 
4862 LIBMDBX_API int mdbx_reader_check(MDBX_env *env, int *dead);
4863 
4877  int *percent);
4878 
4897 LIBMDBX_API int mdbx_thread_register(const MDBX_env *env);
4898 
4913 
4985 typedef int(MDBX_hsr_func)(const MDBX_env *env, const MDBX_txn *txn,
4986  mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard,
4987  unsigned gap, size_t space,
4988  int retry) MDBX_CXX17_NOEXCEPT;
4989 
5007 LIBMDBX_API int mdbx_env_set_hsr(MDBX_env *env, MDBX_hsr_func *hsr_callback);
5008 
5021 mdbx_env_get_hsr(const MDBX_env *env);
5022 
5041 };
5042 #ifndef __cplusplus
5044 #endif
5045 
5047 #define MDBX_PGWALK_MAIN ((const char *)((ptrdiff_t)0))
5048 
5049 #define MDBX_PGWALK_GC ((const char *)((ptrdiff_t)-1))
5050 
5051 #define MDBX_PGWALK_META ((const char *)((ptrdiff_t)-2))
5052 
5055  const uint64_t pgno, const unsigned number, void *const ctx, const int deep,
5056  const char *const dbi, const size_t page_size, const MDBX_page_type_t type,
5057  const MDBX_error_t err, const size_t nentries, const size_t payload_bytes,
5058  const size_t header_bytes, const size_t unused_bytes) MDBX_CXX17_NOEXCEPT;
5059 
5062  void *ctx, bool dont_check_keys_ordering);
5063 
5070 LIBMDBX_API int mdbx_env_open_for_recovery(MDBX_env *env, const char *pathname,
5071  unsigned target_meta,
5072  bool writeable);
5073 
5079 LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta);
5080 
5083 /**** Attribute support functions for Nexenta (scheduled for removal)
5084  * *****************************************************************/
5085 #if defined(MDBX_NEXENTA_ATTRS) || defined(DOXYGEN)
5086 
5089 typedef uint_fast64_t mdbx_attr_t;
5090 
5127  MDBX_val *data, mdbx_attr_t attr,
5128  MDBX_put_flags_t flags);
5129 
5175 LIBMDBX_API int mdbx_put_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
5176  MDBX_val *data, mdbx_attr_t attr,
5177  MDBX_put_flags_t flags);
5178 
5196 LIBMDBX_API int mdbx_set_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
5197  MDBX_val *data, mdbx_attr_t attr);
5198 
5219  MDBX_val *data, mdbx_attr_t *pattr,
5220  MDBX_cursor_op op);
5221 
5249 LIBMDBX_API int mdbx_get_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key,
5250  MDBX_val *data, mdbx_attr_t *pattr);
5252 #endif /* MDBX_NEXENTA_ATTRS */
5253 
5256 /*******************************************************************************
5257  * Workaround for mmaped-lookahead-cross-page-boundary bug
5258  * in an obsolete versions of Elbrus's libc and kernels. */
5259 #if defined(__e2k__) && defined(MDBX_E2K_MLHCPB_WORKAROUND) && \
5260  MDBX_E2K_MLHCPB_WORKAROUND
5261 LIBMDBX_API int mdbx_e2k_memcmp_bug_workaround(const void *s1, const void *s2,
5262  size_t n);
5263 LIBMDBX_API int mdbx_e2k_strcmp_bug_workaround(const char *s1, const char *s2);
5264 LIBMDBX_API int mdbx_e2k_strncmp_bug_workaround(const char *s1, const char *s2,
5265  size_t n);
5266 LIBMDBX_API size_t mdbx_e2k_strlen_bug_workaround(const char *s);
5267 LIBMDBX_API size_t mdbx_e2k_strnlen_bug_workaround(const char *s,
5268  size_t maxlen);
5269 #ifdef __cplusplus
5270 namespace std {
5271 inline int mdbx_e2k_memcmp_bug_workaround(const void *s1, const void *s2,
5272  size_t n) {
5273  return ::mdbx_e2k_memcmp_bug_workaround(s1, s2, n);
5274 }
5275 inline int mdbx_e2k_strcmp_bug_workaround(const char *s1, const char *s2) {
5276  return ::mdbx_e2k_strcmp_bug_workaround(s1, s2);
5277 }
5278 inline int mdbx_e2k_strncmp_bug_workaround(const char *s1, const char *s2,
5279  size_t n) {
5280  return ::mdbx_e2k_strncmp_bug_workaround(s1, s2, n);
5281 }
5282 inline size_t mdbx_e2k_strlen_bug_workaround(const char *s) {
5283  return ::mdbx_e2k_strlen_bug_workaround(s);
5284 }
5285 inline size_t mdbx_e2k_strnlen_bug_workaround(const char *s, size_t maxlen) {
5286  return ::mdbx_e2k_strnlen_bug_workaround(s, maxlen);
5287 }
5288 } // namespace std
5289 #endif /* __cplusplus */
5290 
5291 #include <string.h>
5292 #include <strings.h>
5293 #undef memcmp
5294 #define memcmp mdbx_e2k_memcmp_bug_workaround
5295 #undef bcmp
5296 #define bcmp mdbx_e2k_memcmp_bug_workaround
5297 #undef strcmp
5298 #define strcmp mdbx_e2k_strcmp_bug_workaround
5299 #undef strncmp
5300 #define strncmp mdbx_e2k_strncmp_bug_workaround
5301 #undef strlen
5302 #define strlen mdbx_e2k_strlen_bug_workaround
5303 #undef strnlen
5304 #define strnlen mdbx_e2k_strnlen_bug_workaround
5305 #endif /* MDBX_E2K_MLHCPB_WORKAROUND */
5306 
5307 #ifdef __cplusplus
5308 } /* extern "C" */
5309 #endif
5310 
5311 #endif /* LIBMDBX_H */
MDBX_EXCLUSIVE
@ MDBX_EXCLUSIVE
Definition: mdbx.h:1031
MDBX_TXN_FULL
@ MDBX_TXN_FULL
Definition: mdbx.h:1690
MDBX_version_info::sourcery
const char * sourcery
Definition: mdbx.h:624
MDBX_envinfo::mi_sys_pagesize
uint32_t mi_sys_pagesize
Definition: mdbx.h:2348
MDBX_RESERVE
@ MDBX_RESERVE
Definition: mdbx.h:1497
MDBX_NEXT_MULTIPLE
@ MDBX_NEXT_MULTIPLE
Definition: mdbx.h:1580
MDBX_UTTERLY_NOSYNC
@ MDBX_UTTERLY_NOSYNC
Definition: mdbx.h:1356
mdbx_dbi_flags
int mdbx_dbi_flags(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:3880
MDBX_envinfo::clone
uint64_t clone
Definition: mdbx.h:2388
MDBX_opt_txn_dp_initial
@ MDBX_opt_txn_dp_initial
Controls the in-process initial allocation size for dirty pages list of a write transaction....
Definition: mdbx.h:2000
MDBX_envinfo::mi_since_sync_seconds16dot16
uint32_t mi_since_sync_seconds16dot16
Definition: mdbx.h:2369
mdbx_key_from_ptrdouble
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit)
MDBX_dbi_state_t
MDBX_dbi_state_t
DBI state bits returted by mdbx_dbi_flags_ex()
Definition: mdbx.h:3849
MDBX_PAGE_NOTFOUND
@ MDBX_PAGE_NOTFOUND
Definition: mdbx.h:1665
MDBX_MAX_DBI
@ MDBX_MAX_DBI
Definition: mdbx.h:765
MDBX_stat::ms_leaf_pages
uint64_t ms_leaf_pages
Definition: mdbx.h:2285
mdbx_cursor_bind
LIBMDBX_API int mdbx_cursor_bind(MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi)
Bind cursor to specified transaction and DBI handle.
MDBX_canary::v
uint64_t v
Definition: mdbx.h:3582
mdbx_cursor_get_attr
LIBMDBX_API int mdbx_cursor_get_attr(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, mdbx_attr_t *pattr, MDBX_cursor_op op)
MDBX_PAGE_FULL
@ MDBX_PAGE_FULL
Definition: mdbx.h:1697
mdbx_cursor_get
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
MDBX_envinfo::split
uint64_t split
Definition: mdbx.h:2390
MDBX_BAD_VALSIZE
@ MDBX_BAD_VALSIZE
Definition: mdbx.h:1728
MDBX_build_info::compiler
const char * compiler
Definition: mdbx.h:634
MDBX_SET_KEY
@ MDBX_SET_KEY
Definition: mdbx.h:1598
MDBX_canary::z
uint64_t z
Definition: mdbx.h:3582
mdbx_limits_pgsize_min
MDBX_NOTHROW_CONST_FUNCTION intptr_t mdbx_limits_pgsize_min(void)
Returns the minimal database page size in bytes.
Definition: mdbx.h:2935
MDBX_opt_spill_max_denominator
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition: mdbx.h:2016
MDBX_version_info
libmdbx version information
Definition: mdbx.h:613
MDBX_TXN_NOMETASYNC
@ MDBX_TXN_NOMETASYNC
Definition: mdbx.h:1401
MDBX_txn_info::txn_reader_lag
uint64_t txn_reader_lag
Definition: mdbx.h:3304
mdbx_filehandle_t
int mdbx_filehandle_t
Definition: mdbx.h:196
mdbx_env_stat_ex
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.
MDBX_EBADSIGN
@ MDBX_EBADSIGN
Definition: mdbx.h:1753
mdbx_set_attr
LIBMDBX_API int mdbx_set_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, mdbx_attr_t attr)
MDBX_ENV_JUST_DELETE
@ MDBX_ENV_JUST_DELETE
Just delete the environment's files and directory if any.
Definition: mdbx.h:2184
mdbx_double_from_key
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API double mdbx_double_from_key(const MDBX_val)
mdbx_key_from_float
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_float(const float ieee754_32bit)
mdbx_build
LIBMDBX_VERINFO_API const struct MDBX_build_info mdbx_build
libmdbx build information
MDBX_CORRUPTED
@ MDBX_CORRUPTED
Definition: mdbx.h:1668
MDBX_envinfo::upper
uint64_t upper
Definition: mdbx.h:2331
mdbx_txn_begin
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:3262
mdbx_limits_txnsize_max
MDBX_NOTHROW_CONST_FUNCTION 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...
MDBX_subpage_broken
@ MDBX_subpage_broken
Definition: mdbx.h:5040
MDBX_page_leaf
@ MDBX_page_leaf
Definition: mdbx.h:5036
mdbx_env_set_userctx
LIBMDBX_API int mdbx_env_set_userctx(MDBX_env *env, void *ctx)
Sets application information (a context pointer) associated with the environment.
MDBX_envinfo::mi_meta2_txnid
uint64_t mi_meta2_txnid
Definition: mdbx.h:2344
mdbx_env_get_flags
LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags)
Get environment flags.
MDBX_subpage_leaf
@ MDBX_subpage_leaf
Definition: mdbx.h:5038
mdbx_cursor_open
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.
MDBX_DUPFIXED
@ MDBX_DUPFIXED
Definition: mdbx.h:1436
MDBX_opt_max_db
@ MDBX_opt_max_db
Controls the maximum number of named databases for the environment.
Definition: mdbx.h:1908
mdbx_env_create
LIBMDBX_API int mdbx_env_create(MDBX_env **penv)
Create an MDBX environment instance.
MDBX_PREV_MULTIPLE
@ MDBX_PREV_MULTIPLE
Definition: mdbx.h:1605
mdbx_limits_dbsize_max
MDBX_NOTHROW_CONST_FUNCTION 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.
MDBX_txn_info::txn_space_leftover
uint64_t txn_space_leftover
Definition: mdbx.h:3330
MDBX_commit_latency::write
uint32_t write
Duration of writing dirty/modified data pages to a filesystem, i.e. the summary duration of a write()...
Definition: mdbx.h:3405
MDBX_SET_LOWERBOUND
@ MDBX_SET_LOWERBOUND
Definition: mdbx.h:1619
mdbx_thread_unregister
LIBMDBX_API int mdbx_thread_unregister(const MDBX_env *env)
Unregisters the current thread as a reader for the environment.
MDBX_DBG_DUMP
@ MDBX_DBG_DUMP
Definition: mdbx.h:875
MDBX_envinfo::mi_pgop_stat
struct MDBX_envinfo::@3 mi_pgop_stat
mdbx_get_keycmp
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API MDBX_cmp_func * mdbx_get_keycmp(MDBX_db_flags_t flags)
Returns default internal key's comparator for given database flags.
MDBX_opt_loose_limit
@ 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:1968
MDBX_env_flags_t
MDBX_env_flags_t
Environment flags.
Definition: mdbx.h:964
mdbx_strerror_ANSI2OEM
const LIBMDBX_API char * mdbx_strerror_ANSI2OEM(int errnum)
MDBX_CP_DEFAULTS
@ MDBX_CP_DEFAULTS
Definition: mdbx.h:1523
MDBX_NOTHROW_PURE_FUNCTION
#define MDBX_NOTHROW_PURE_FUNCTION
Definition: mdbx.h:270
MDBX_envinfo::mi_autosync_period_seconds16dot16
uint32_t mi_autosync_period_seconds16dot16
Definition: mdbx.h:2372
mdbx_canary_put
LIBMDBX_API int mdbx_canary_put(MDBX_txn *txn, const MDBX_canary *canary)
Set integers markers (aka "canary") associated with the environment.
mdbx_txn_renew
LIBMDBX_API int mdbx_txn_renew(MDBX_txn *txn)
Renew a read-only transaction.
mdbx_env_close_ex
LIBMDBX_API int mdbx_env_close_ex(MDBX_env *env, bool dont_sync)
Close the environment and release the memory map.
mdbx_cursor_on_last
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_BAD_TXN
@ MDBX_BAD_TXN
Definition: mdbx.h:1724
MDBX_NOTFOUND
@ MDBX_NOTFOUND
Definition: mdbx.h:1662
MDBX_TXN_TRY
@ MDBX_TXN_TRY
Definition: mdbx.h:1397
mdbx_get_equal_or_great
LIBMDBX_API int mdbx_get_equal_or_great(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data)
Get equal or great item from a database.
MDBX_build_info
libmdbx build information
Definition: mdbx.h:630
mdbx_estimate_distance
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.
MDBX_stat::ms_overflow_pages
uint64_t ms_overflow_pages
Definition: mdbx.h:2286
MDBX_INCOMPATIBLE
@ MDBX_INCOMPATIBLE
Definition: mdbx.h:1716
MDBX_DEPRECATED
#define MDBX_DEPRECATED
Definition: mdbx.h:322
MDBX_UPSERT
@ MDBX_UPSERT
Definition: mdbx.h:1474
MDBX_envinfo
Information about the environment.
Definition: mdbx.h:2328
MDBX_ACCEDE
@ MDBX_ACCEDE
Definition: mdbx.h:1046
MDBX_debug_flags_t
MDBX_debug_flags_t
Runtime debug flags.
Definition: mdbx.h:857
mdbx_txn_id
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_txn_id(const MDBX_txn *txn)
Return the transaction's ID.
MDBX_MULTIPLE
@ MDBX_MULTIPLE
Definition: mdbx.h:1510
MDBX_stat
Statistics for a database in the environment.
Definition: mdbx.h:2280
MDBX_version_info::git
struct MDBX_version_info::@0 git
MDBX_opt_rp_augment_limit
@ 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:1955
MDBX_LOG_EXTRA
@ MDBX_LOG_EXTRA
Definition: mdbx.h:839
mdbx_txn_get_userctx
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void * mdbx_txn_get_userctx(const MDBX_txn *txn)
Returns an application information (a context pointer) associated with the transaction.
mdbx_env_set_syncbytes
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:2506
MDBX_READERS_FULL
@ MDBX_READERS_FULL
Definition: mdbx.h:1687
MDBX_copy_flags_t
MDBX_copy_flags_t
Environment copy flags.
Definition: mdbx.h:1522
mdbx_jsonInteger_from_key
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int64_t mdbx_jsonInteger_from_key(const MDBX_val)
LIBMDBX_API
#define LIBMDBX_API
Definition: mdbx.h:592
MDBX_NEXT
@ MDBX_NEXT
Definition: mdbx.h:1572
MDBX_UNABLE_EXTEND_MAPSIZE
@ MDBX_UNABLE_EXTEND_MAPSIZE
Definition: mdbx.h:1706
mdbx_env_get_option
LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue)
Gets the value of runtime options from an environment.
mdbx_setup_debug
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.
MDBX_DBG_DONTCHANGE
@ MDBX_DBG_DONTCHANGE
Definition: mdbx.h:894
MDBX_ENV_ENSURE_UNUSED
@ MDBX_ENV_ENSURE_UNUSED
Make sure that the environment is not being used by other processes, or return an error otherwise.
Definition: mdbx.h:2187
mdbx_env_get_syncbytes
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:2524
MDBX_SUCCESS
@ MDBX_SUCCESS
Definition: mdbx.h:1647
MDBX_hsr_func
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) MDBX_CXX17_NOEXCEPT
A Handle-Slow-Readers callback function to resolve database full/overflow issue due to a reader(s) wh...
Definition: mdbx.h:4985
mdbx_env_get_maxvalsize_ex
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_envinfo::mi_unsync_volume
uint64_t mi_unsync_volume
Definition: mdbx.h:2365
mdbx_dbi_flags_ex
LIBMDBX_API int mdbx_dbi_flags_ex(MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state)
Retrieve the DB flags and status for a database handle.
MDBX_LOG_VERBOSE
@ MDBX_LOG_VERBOSE
Definition: mdbx.h:824
mdbx_env_set_maxreaders
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:3000
mdbx_dbi_stat
LIBMDBX_API int mdbx_dbi_stat(MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes)
Retrieve statistics for a database.
MDBX_CP_FORCE_DYNAMIC_SIZE
@ MDBX_CP_FORCE_DYNAMIC_SIZE
Definition: mdbx.h:1530
mdbx_strerror_r_ANSI2OEM
const LIBMDBX_API char * mdbx_strerror_r_ANSI2OEM(int errnum, char *buf, size_t buflen)
MDBX_envinfo::cow
uint64_t cow
Definition: mdbx.h:2387
mdbx_estimate_move
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.
MDBX_envinfo::unspill
uint64_t unspill
Definition: mdbx.h:2393
mdbx_key_from_int32
MDBX_NOTHROW_CONST_FUNCTION uint32_t mdbx_key_from_int32(const int32_t i32)
Definition: mdbx.h:3785
mdbx_cursor_get_batch
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.
MDBX_debug_func
void MDBX_debug_func(MDBX_log_level_t loglevel, const char *function, int line, const char *fmt, va_list args) MDBX_CXX17_NOEXCEPT
A debug-logger callback function, called before printing the message and aborting.
Definition: mdbx.h:908
MDBX_ENOFILE
@ MDBX_ENOFILE
Definition: mdbx.h:1802
mdbx_env_get_syncperiod
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:2587
MDBX_EROFS
@ MDBX_EROFS
Definition: mdbx.h:1797
MDBX_canary::x
uint64_t x
Definition: mdbx.h:3582
mdbx_cursor_dbi
LIBMDBX_API MDBX_dbi mdbx_cursor_dbi(const MDBX_cursor *cursor)
Return the cursor's database handle.
mdbx_key_from_ptrfloat
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit)
mdbx_get_ex
LIBMDBX_API int mdbx_get_ex(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count)
Get items from a database and optionally number of data items for a given key.
mdbx_get_attr
LIBMDBX_API int mdbx_get_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, mdbx_attr_t *pattr)
MDBX_NOSUBDIR
@ MDBX_NOSUBDIR
Definition: mdbx.h:983
mdbx_limits_pgsize_max
MDBX_NOTHROW_CONST_FUNCTION intptr_t mdbx_limits_pgsize_max(void)
Returns the maximal database page size in bytes.
Definition: mdbx.h:2941
MDBX_cursor_op
MDBX_cursor_op
Cursor operations.
Definition: mdbx.h:1543
mdbx_cursor_eof
MDBX_NOTHROW_PURE_FUNCTION 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...
MDBX_LAST
@ MDBX_LAST
Definition: mdbx.h:1566
MDBX_envinfo::mi_meta2_sign
uint64_t mi_meta2_sign
Definition: mdbx.h:2344
MDBX_EREMOTE
@ MDBX_EREMOTE
Definition: mdbx.h:1803
mdbx_cursor_put_attr
LIBMDBX_API int mdbx_cursor_put_attr(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, mdbx_attr_t attr, MDBX_put_flags_t flags)
MDBX_DBG_LEGACY_MULTIOPEN
@ MDBX_DBG_LEGACY_MULTIOPEN
Definition: mdbx.h:878
MDBX_txn_info::txn_id
uint64_t txn_id
Definition: mdbx.h:3298
mdbx_txn_env
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
MDBX_envinfo::meta2
struct MDBX_envinfo::@2::@4 meta2
mdbx_attr_t
uint_fast64_t mdbx_attr_t
Definition: mdbx.h:5089
MDBX_NOMEMINIT
@ MDBX_NOMEMINIT
Definition: mdbx.h:1144
MDBX_MAP_FULL
@ MDBX_MAP_FULL
Definition: mdbx.h:1681
MDBX_COALESCE
@ MDBX_COALESCE
Definition: mdbx.h:1156
mdbx_env_get_userctx
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
MDBX_env
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition: mdbx.h:692
MDBX_commit_latency::ending
uint32_t ending
Duration of transaction ending (releasing resources).
Definition: mdbx.h:3410
MDBX_version_info::commit
const char * commit
Definition: mdbx.h:621
MDBX_MAXDATASIZE
@ MDBX_MAXDATASIZE
Definition: mdbx.h:768
mdbx_tid_t
pthread_t mdbx_tid_t
Definition: mdbx.h:198
mdbx_env_delete
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.
mdbx_env_get_maxkeysize_ex
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_commit_latency::audit
uint32_t audit
Duration of internal audit if enabled.
Definition: mdbx.h:3402
MDBX_DBG_LEGACY_OVERLAP
@ MDBX_DBG_LEGACY_OVERLAP
Definition: mdbx.h:881
MDBX_envinfo::mi_autosync_threshold
uint64_t mi_autosync_threshold
Definition: mdbx.h:2367
MDBX_ENV_WAIT_FOR_UNUSED
@ MDBX_ENV_WAIT_FOR_UNUSED
Wait until other processes closes the environment before deletion.
Definition: mdbx.h:2190
MDBX_ENOMEM
@ MDBX_ENOMEM
Definition: mdbx.h:1796
MDBX_stat::ms_branch_pages
uint64_t ms_branch_pages
Definition: mdbx.h:2284
MDBX_preserve_func
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition: mdbx.h:4149
MDBX_DBI_FRESH
@ MDBX_DBI_FRESH
Definition: mdbx.h:3855
MDBX_DB_DEFAULTS
@ MDBX_DB_DEFAULTS
Definition: mdbx.h:1419
mdbx_cursor_close
LIBMDBX_API void mdbx_cursor_close(MDBX_cursor *cursor)
Close a cursor handle.
mdbx_cursor_on_first
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_envinfo::mi_meta0_txnid
uint64_t mi_meta0_txnid
Definition: mdbx.h:2342
mdbx_key_from_int64
MDBX_NOTHROW_CONST_FUNCTION uint64_t mdbx_key_from_int64(const int64_t i64)
Definition: mdbx.h:3781
MDBX_PREV_NODUP
@ MDBX_PREV_NODUP
Definition: mdbx.h:1592
mdbx_liberr2str
MDBX_NOTHROW_PURE_FUNCTION const LIBMDBX_API char * mdbx_liberr2str(int errnum)
MDBX_DBG_NONE
@ MDBX_DBG_NONE
Definition: mdbx.h:858
MDBX_assert_func
void MDBX_assert_func(const MDBX_env *env, const char *msg, const char *function, unsigned line) MDBX_CXX17_NOEXCEPT
A callback function for most MDBX assert() failures, called before printing the message and aborting.
Definition: mdbx.h:928
MDBX_NODUPDATA
@ MDBX_NODUPDATA
Definition: mdbx.h:1482
mdbx_drop
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a database.
MDBX_MAX_PAGESIZE
@ MDBX_MAX_PAGESIZE
Definition: mdbx.h:774
mdbx_del
LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data)
Delete items from a database.
mdbx_env_sync_poll
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:2479
mdbx_env_open
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.
MDBX_PAGEPERTURB
@ MDBX_PAGEPERTURB
Definition: mdbx.h:1183
mdbx_txn_abort
LIBMDBX_API int mdbx_txn_abort(MDBX_txn *txn)
Abandon all the operations of the transaction instead of saving them.
mdbx_env_set_maxdbs
int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs)
Set the maximum number of named databases for the environment.
Definition: mdbx.h:3046
MDBX_version_info::minor
uint8_t minor
Definition: mdbx.h:615
MDBX_opt_spill_parent4child_denominator
@ 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:2055
MDBX_envinfo::mi_mapsize
uint64_t mi_mapsize
Definition: mdbx.h:2336
MDBX_CURSOR_FULL
@ MDBX_CURSOR_FULL
Definition: mdbx.h:1694
mdbx_cursor_set_userctx
LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx)
Set application information associated with the MDBX_cursor.
mdbx_txn_break
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken.
mdbx_env_set_mapsize
MDBX_DEPRECATED int mdbx_env_set_mapsize(MDBX_env *env, size_t size)
Definition: mdbx.h:2911
MDBX_LAST_ADDED_ERRCODE
@ MDBX_LAST_ADDED_ERRCODE
Definition: mdbx.h:1774
mdbx_key_from_jsonInteger
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)
MDBX_build_info::flags
const char * flags
Definition: mdbx.h:635
MDBX_txn_info::txn_space_retired
uint64_t txn_space_retired
Definition: mdbx.h:3323
MDBX_envinfo::meta0
struct MDBX_envinfo::@2::@4 meta0
MDBX_envinfo::current
uint64_t current
Definition: mdbx.h:2332
MDBX_TXN_OVERLAPPING
@ MDBX_TXN_OVERLAPPING
Definition: mdbx.h:1771
mdbx_cursor_copy
LIBMDBX_API int mdbx_cursor_copy(const MDBX_cursor *src, MDBX_cursor *dest)
Copy cursor position and state.
MDBX_SET_RANGE
@ MDBX_SET_RANGE
Definition: mdbx.h:1601
MDBX_VERSION_MISMATCH
@ MDBX_VERSION_MISMATCH
Definition: mdbx.h:1675
mdbx_float_from_key
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API float mdbx_float_from_key(const MDBX_val)
MDBX_REVERSEKEY
@ MDBX_REVERSEKEY
Definition: mdbx.h:1422
MDBX_LOG_WARN
@ MDBX_LOG_WARN
Definition: mdbx.h:813
MDBX_EACCESS
@ MDBX_EACCESS
Definition: mdbx.h:1795
MDBX_GET_CURRENT
@ MDBX_GET_CURRENT
Definition: mdbx.h:1558
MDBX_opt_max_readers
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition: mdbx.h:1924
MDBX_NOMETASYNC
@ MDBX_NOMETASYNC
Definition: mdbx.h:1255
MDBX_page_meta
@ MDBX_page_meta
Definition: mdbx.h:5033
MDBX_envinfo::lower
uint64_t lower
Definition: mdbx.h:2330
MDBX_dbi
uint32_t MDBX_dbi
A handle for an individual database (key-value spaces) in the environment.
Definition: mdbx.h:715
mdbx_int32_from_key
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int32_t mdbx_int32_from_key(const MDBX_val)
MDBX_PANIC
@ MDBX_PANIC
Definition: mdbx.h:1672
mdbx_dump_val
const LIBMDBX_API char * mdbx_dump_val(const MDBX_val *key, char *const buf, const size_t bufsize)
Dump given MDBX_val to the buffer.
MDBX_NOTLS
@ MDBX_NOTLS
Definition: mdbx.h:1100
mdbx_txn_set_userctx
LIBMDBX_API int mdbx_txn_set_userctx(MDBX_txn *txn, void *ctx)
Sets application information associated (a context pointer) with the transaction.
MDBX_commit_latency::preparation
uint32_t preparation
Duration of preparation (commit child transactions, update sub-databases records and cursors destroyi...
Definition: mdbx.h:3398
MDBX_envinfo::mi_dxb_pagesize
uint32_t mi_dxb_pagesize
Definition: mdbx.h:2347
MDBX_PROBLEM
@ MDBX_PROBLEM
Definition: mdbx.h:1735
MDBX_SET_UPPERBOUND
@ MDBX_SET_UPPERBOUND
Definition: mdbx.h:1633
MDBX_version_info::datetime
const char * datetime
Definition: mdbx.h:619
MDBX_stat::ms_psize
uint32_t ms_psize
Definition: mdbx.h:2281
MDBX_error_t
MDBX_error_t
Errors and return codes.
Definition: mdbx.h:1645
MDBX_APPENDDUP
@ MDBX_APPENDDUP
Definition: mdbx.h:1506
MDBX_constants
MDBX_constants
Definition: mdbx.h:763
mdbx_limits_keysize_max
MDBX_NOTHROW_CONST_FUNCTION 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 database flags, or -1 if pagesize is invali...
MDBX_envinfo::mi_recent_txnid
uint64_t mi_recent_txnid
Definition: mdbx.h:2338
MDBX_envinfo::mi_mode
uint32_t mi_mode
Definition: mdbx.h:2378
MDBX_DBG_AUDIT
@ MDBX_DBG_AUDIT
Definition: mdbx.h:867
mdbx_reader_list
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.
MDBX_SYNC_DURABLE
@ MDBX_SYNC_DURABLE
Definition: mdbx.h:1237
MDBX_envinfo::mi_numreaders
uint32_t mi_numreaders
Definition: mdbx.h:2346
MDBX_option_t
MDBX_option_t
MDBX environment options.
Definition: mdbx.h:1899
mdbx_env_open_for_recovery
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_env_set_flags
LIBMDBX_API int mdbx_env_set_flags(MDBX_env *env, MDBX_env_flags_t flags, bool onoff)
Set environment flags.
MDBX_db_flags_t
MDBX_db_flags_t
Database flags.
Definition: mdbx.h:1417
mdbx_cursor_count
LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount)
Return count of duplicates for current key.
MDBX_version_info::revision
uint32_t revision
Definition: mdbx.h:617
MDBX_envinfo::mi_self_latter_reader_txnid
uint64_t mi_self_latter_reader_txnid
Definition: mdbx.h:2340
mdbx_default_pagesize
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API size_t mdbx_default_pagesize(void)
Returns the default size of database page for the current system.
mdbx_env_get_maxdbs
int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs)
Get the maximum number of named databases for the environment.
Definition: mdbx.h:3060
MDBX_stat::ms_mod_txnid
uint64_t ms_mod_txnid
Definition: mdbx.h:2288
MDBX_NORDAHEAD
@ MDBX_NORDAHEAD
Definition: mdbx.h:1121
mdbx_replace_ex
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)
MDBX_txn_flags_t
MDBX_txn_flags_t
Definition: mdbx.h:1371
MDBX_version_info::release
uint16_t release
Definition: mdbx.h:616
MDBX_FIRST_LMDB_ERRCODE
@ MDBX_FIRST_LMDB_ERRCODE
Definition: mdbx.h:1659
MDBX_DB_ACCEDE
@ MDBX_DB_ACCEDE
Definition: mdbx.h:1459
MDBX_DBI_STALE
@ MDBX_DBI_STALE
Definition: mdbx.h:3853
MDBX_MAPASYNC
@ MDBX_MAPASYNC
Definition: mdbx.h:1313
mdbx_dcmp
MDBX_NOTHROW_PURE_FUNCTION 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 database.
MDBX_txn_info
Information about the transaction.
Definition: mdbx.h:3295
MDBX_page_dupfixed_leaf
@ MDBX_page_dupfixed_leaf
Definition: mdbx.h:5037
MDBX_envinfo::mi_last_pgno
uint64_t mi_last_pgno
Definition: mdbx.h:2337
MDBX_subpage_dupfixed_leaf
@ MDBX_subpage_dupfixed_leaf
Definition: mdbx.h:5039
mdbx_env_copy
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.
MDBX_envinfo::meta1
struct MDBX_envinfo::@2::@4 meta1
mdbx_reader_check
LIBMDBX_API int mdbx_reader_check(MDBX_env *env, int *dead)
Check for stale entries in the reader lock table.
mdbx_env_copy2fd
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.
MDBX_LOG_NOTICE
@ MDBX_LOG_NOTICE
Definition: mdbx.h:819
mdbx_env_get_maxreaders
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:3015
MDBX_opt_dp_reserve_limit
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition: mdbx.h:1982
MDBX_DBG_DONT_UPGRADE
@ MDBX_DBG_DONT_UPGRADE
Definition: mdbx.h:886
mdbx_txn_begin_ex
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.
MDBX_BAD_DBI
@ MDBX_BAD_DBI
Definition: mdbx.h:1732
mdbx_key_from_double
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_double(const double ieee754_64bit)
mdbx_env_set_option
LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value)
Sets the value of a runtime options for an environment.
mdbx_txn_info
LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt)
Return information about the MDBX transaction.
MDBX_opt_spill_min_denominator
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition: mdbx.h:2032
mdbx_env_get_maxkeysize
MDBX_NOTHROW_PURE_FUNCTION MDBX_DEPRECATED LIBMDBX_API int mdbx_env_get_maxkeysize(const MDBX_env *env)
MDBX_EINVAL
@ MDBX_EINVAL
Definition: mdbx.h:1794
MDBX_put_flags_t
MDBX_put_flags_t
Data changing flags.
Definition: mdbx.h:1472
MDBX_FIRST
@ MDBX_FIRST
Definition: mdbx.h:1545
MDBX_PRINTF_ARGS
#define MDBX_PRINTF_ARGS(format_index, first_arg)
Definition: mdbx.h:470
MDBX_txn_info::txn_space_dirty
uint64_t txn_space_dirty
Definition: mdbx.h:3337
MDBX_env_delete_mode_t
MDBX_env_delete_mode_t
Deletion modes for mdbx_env_delete().
Definition: mdbx.h:2177
MDBX_CP_COMPACT
@ MDBX_CP_COMPACT
Definition: mdbx.h:1527
mdbx_env_set_syncperiod
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:2567
MDBX_INVALID
@ MDBX_INVALID
Definition: mdbx.h:1678
MDBX_LOG_FATAL
@ MDBX_LOG_FATAL
Definition: mdbx.h:801
MDBX_RDONLY
@ MDBX_RDONLY
Definition: mdbx.h:1001
MDBX_SAFE_NOSYNC
@ MDBX_SAFE_NOSYNC
Definition: mdbx.h:1306
MDBX_DBI_DIRTY
@ MDBX_DBI_DIRTY
Definition: mdbx.h:3851
MDBX_stat::ms_depth
uint32_t ms_depth
Definition: mdbx.h:2283
MDBX_envinfo::mi_maxreaders
uint32_t mi_maxreaders
Definition: mdbx.h:2345
mdbx_env_pgwalk
LIBMDBX_API int mdbx_env_pgwalk(MDBX_txn *txn, MDBX_pgvisitor_func *visitor, void *ctx, bool dont_check_keys_ordering)
B-tree traversal function.
mdbx_cursor_get_userctx
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void * mdbx_cursor_get_userctx(const MDBX_cursor *cursor)
Get the application information associated with the MDBX_cursor.
MDBX_txn_info::txn_space_used
uint64_t txn_space_used
Definition: mdbx.h:3308
MDBX_page_branch
@ MDBX_page_branch
Definition: mdbx.h:5035
mdbx_cmp
MDBX_NOTHROW_PURE_FUNCTION 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 database.
MDBX_reader_list_func
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) MDBX_CXX17_NOEXCEPT
A callback function used to enumerate the reader lock table.
Definition: mdbx.h:4835
MDBX_opt_sync_bytes
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition: mdbx.h:1930
MDBX_DBG_JITTER
@ MDBX_DBG_JITTER
Definition: mdbx.h:871
MDBX_LOG_ERROR
@ MDBX_LOG_ERROR
Definition: mdbx.h:807
MDBX_NOOVERWRITE
@ MDBX_NOOVERWRITE
Definition: mdbx.h:1477
MDBX_MIN_PAGESIZE
@ MDBX_MIN_PAGESIZE
Definition: mdbx.h:771
MDBX_opt_txn_dp_limit
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition: mdbx.h:1996
MDBX_envinfo::mi_bootid
struct MDBX_envinfo::@2 mi_bootid
A mostly unique ID that is regenerated on each boot.
MDBX_envinfo::x
uint64_t x
Definition: mdbx.h:2360
mdbx_canary_get
LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary)
Returns fours integers markers (aka "canary") associated with the environment.
mdbx_cursor_put
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
MDBX_envinfo::grow
uint64_t grow
Definition: mdbx.h:2334
MDBX_envinfo::shrink
uint64_t shrink
Definition: mdbx.h:2333
mdbx_env_turn_for_recovery
LIBMDBX_API int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target_meta)
Turn database to the specified meta-page.
mdbx_strerror
const LIBMDBX_API char * mdbx_strerror(int errnum)
Return a string describing a given error code.
MDBX_commit_latency::gc
uint32_t gc
Duration of GC/freeDB handling & updation.
Definition: mdbx.h:3400
MDBX_NOTHROW_CONST_FUNCTION
#define MDBX_NOTHROW_CONST_FUNCTION
Definition: mdbx.h:311
mdbx_limits_valsize_max
MDBX_NOTHROW_CONST_FUNCTION 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 database flags, or -1 if pagesize is inval...
MDBX_PREV
@ MDBX_PREV
Definition: mdbx.h:1586
mdbx_replace
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 database.
MDBX_txn_info::txn_space_limit_soft
uint64_t txn_space_limit_soft
Definition: mdbx.h:3311
mdbx_dbi_open_ex
MDBX_DEPRECATED 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)
mdbx_get
LIBMDBX_API int mdbx_get(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a database.
mdbx_txn_flags
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
mdbx_env_set_assert
LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func)
Set or reset the assert() callback of the environment.
MDBX_commit_latency
Latency of commit stages in 1/65536 of seconds units.
Definition: mdbx.h:3395
LIBMDBX_VERINFO_API
#define LIBMDBX_VERINFO_API
Definition: mdbx.h:609
mdbx_panic
LIBMDBX_API void mdbx_panic(const char *fmt,...) MDBX_PRINTF_ARGS(1
Panics with message and causes abnormal process termination.
mdbx_put
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 database.
mdbx_thread_register
LIBMDBX_API int mdbx_thread_register(const MDBX_env *env)
Registers the current thread as a reader for the environment.
MDBX_envinfo::mi_meta1_sign
uint64_t mi_meta1_sign
Definition: mdbx.h:2343
mdbx_env_sync
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:2472
MDBX_envinfo::mi_meta1_txnid
uint64_t mi_meta1_txnid
Definition: mdbx.h:2343
mdbx_env_info
MDBX_DEPRECATED int mdbx_env_info(const MDBX_env *env, MDBX_envinfo *info, size_t bytes)
Return information about the MDBX environment.
Definition: mdbx.h:2427
MDBX_TXN_READWRITE
@ MDBX_TXN_READWRITE
Definition: mdbx.h:1376
MDBX_GET_MULTIPLE
@ MDBX_GET_MULTIPLE
Definition: mdbx.h:1563
MDBX_TXN_RDONLY
@ MDBX_TXN_RDONLY
Definition: mdbx.h:1382
MDBX_commit_latency::sync
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:3408
MDBX_page_type_t
MDBX_page_type_t
Page types for traverse the b-tree.
Definition: mdbx.h:5031
MDBX_REVERSEDUP
@ MDBX_REVERSEDUP
Definition: mdbx.h:1444
MDBX_SET
@ MDBX_SET
Definition: mdbx.h:1595
MDBX_canary::y
uint64_t y
Definition: mdbx.h:3582
MDBX_version_info::tree
const char * tree
Definition: mdbx.h:620
mdbx_cursor_txn
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
MDBX_build_info::target
const char * target
Definition: mdbx.h:632
mdbx_txn_straggler
MDBX_DEPRECATED LIBMDBX_API int mdbx_txn_straggler(const MDBX_txn *txn, int *percent)
Returns a lag of the reading for the given transaction.
MDBX_txn
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition: mdbx.h:703
MDBX_page_large
@ MDBX_page_large
Definition: mdbx.h:5034
MDBX_page_broken
@ MDBX_page_broken
Definition: mdbx.h:5032
mdbx_env_info_ex
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.
MDBX_CXX17_NOEXCEPT
#define MDBX_CXX17_NOEXCEPT
Definition: mdbx.h:393
MDBX_build_info::datetime
const char * datetime
Definition: mdbx.h:631
MDBX_BAD_RSLOT
@ MDBX_BAD_RSLOT
Definition: mdbx.h:1720
MDBX_envinfo::mi_meta0_sign
uint64_t mi_meta0_sign
Definition: mdbx.h:2342
MDBX_RESULT_FALSE
@ MDBX_RESULT_FALSE
Definition: mdbx.h:1650
MDBX_TXN_RDONLY_PREPARE
@ MDBX_TXN_RDONLY_PREPARE
Definition: mdbx.h:1391
mdbx_dbi_sequence
LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment)
Sequence generation for a database.
MDBX_APPEND
@ MDBX_APPEND
Definition: mdbx.h:1501
mdbx_dbi_close
LIBMDBX_API int mdbx_dbi_close(MDBX_env *env, MDBX_dbi dbi)
Close a database handle. Normally unnecessary.
MDBX_CURRENT
@ MDBX_CURRENT
Definition: mdbx.h:1488
MDBX_LOG_DEBUG
@ MDBX_LOG_DEBUG
Definition: mdbx.h:829
MDBX_envinfo::newly
uint64_t newly
Definition: mdbx.h:2386
MDBX_THREAD_MISMATCH
@ MDBX_THREAD_MISMATCH
Definition: mdbx.h:1768
MDBX_NEXT_NODUP
@ MDBX_NEXT_NODUP
Definition: mdbx.h:1583
mdbx_env_get_fd
LIBMDBX_API int mdbx_env_get_fd(const MDBX_env *env, mdbx_filehandle_t *fd)
Return the file descriptor for the given environment.
MDBX_LOG_DONTCHANGE
@ MDBX_LOG_DONTCHANGE
Definition: mdbx.h:846
MDBX_TOO_LARGE
@ MDBX_TOO_LARGE
Definition: mdbx.h:1764
MDBX_envinfo::y
uint64_t y
Definition: mdbx.h:2360
MDBX_txn_info::txn_space_limit_hard
uint64_t txn_space_limit_hard
Definition: mdbx.h:3315
mdbx_dbi_open
LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi)
Open or Create a database in the environment.
MDBX_LOG_TRACE
@ MDBX_LOG_TRACE
Definition: mdbx.h:834
mdbx_txn_reset
LIBMDBX_API int mdbx_txn_reset(MDBX_txn *txn)
Reset a read-only transaction.
mdbx_get_datacmp
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API MDBX_cmp_func * mdbx_get_datacmp(MDBX_db_flags_t flags)
Returns default internal data's comparator for given database flags.
MDBX_WANNA_RECOVERY
@ MDBX_WANNA_RECOVERY
Definition: mdbx.h:1757
MDBX_LIFORECLAIM
@ MDBX_LIFORECLAIM
Definition: mdbx.h:1180
MDBX_version_info::describe
const char * describe
Definition: mdbx.h:622
mdbx_env_set_hsr
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 ...
MDBX_commit_latency::whole
uint32_t whole
The total duration of a commit.
Definition: mdbx.h:3412
mdbx_env_set_geometry
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...
mdbx_int64_from_key
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int64_t mdbx_int64_from_key(const MDBX_val)
MDBX_EINTR
@ MDBX_EINTR
Definition: mdbx.h:1801
MDBX_DBS_FULL
@ MDBX_DBS_FULL
Definition: mdbx.h:1684
MDBX_INTEGERDUP
@ MDBX_INTEGERDUP
Definition: mdbx.h:1441
MDBX_envinfo::mi_geo
struct MDBX_envinfo::@1 mi_geo
mdbx_dbi_dupsort_depthmask
LIBMDBX_API int mdbx_dbi_dupsort_depthmask(MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask)
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given database.
MDBX_GET_BOTH_RANGE
@ MDBX_GET_BOTH_RANGE
Definition: mdbx.h:1555
MDBX_RESULT_TRUE
@ MDBX_RESULT_TRUE
Definition: mdbx.h:1653
mdbx_pid_t
pid_t mdbx_pid_t
Definition: mdbx.h:197
MDBX_KEYEXIST
@ MDBX_KEYEXIST
Definition: mdbx.h:1656
MDBX_pgvisitor_func
int MDBX_pgvisitor_func(const uint64_t pgno, const unsigned number, void *const ctx, const int deep, const char *const dbi, const size_t page_size, const MDBX_page_type_t type, const MDBX_error_t err, const size_t nentries, const size_t payload_bytes, const size_t header_bytes, const size_t unused_bytes) MDBX_CXX17_NOEXCEPT
Callback function for traverse the b-tree.
Definition: mdbx.h:5054
MDBX_EKEYMISMATCH
@ MDBX_EKEYMISMATCH
Definition: mdbx.h:1760
MDBX_ALLDUPS
@ MDBX_ALLDUPS
Definition: mdbx.h:1493
mdbx_cursor_create
LIBMDBX_API MDBX_cursor * mdbx_cursor_create(void *context)
Create a cursor handle but not bind it to transaction nor DBI handle.
MDBX_NEXT_DUP
@ MDBX_NEXT_DUP
Definition: mdbx.h:1575
MDBX_LAST_DUP
@ MDBX_LAST_DUP
Definition: mdbx.h:1569
MDBX_WRITEMAP
@ MDBX_WRITEMAP
Definition: mdbx.h:1077
MDBX_ENODATA
@ MDBX_ENODATA
Definition: mdbx.h:1792
MDBX_PREV_DUP
@ MDBX_PREV_DUP
Definition: mdbx.h:1589
mdbx_env_stat
MDBX_DEPRECATED int mdbx_env_stat(const MDBX_env *env, MDBX_stat *stat, size_t bytes)
Return statistics about the MDBX environment.
Definition: mdbx.h:2320
MDBX_val
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the database.
Definition: mdbx.h:760
MDBX_FIRST_ADDED_ERRCODE
@ MDBX_FIRST_ADDED_ERRCODE
Definition: mdbx.h:1745
MDBX_BUSY
@ MDBX_BUSY
Definition: mdbx.h:1742
mdbx_is_dirty
MDBX_NOTHROW_PURE_FUNCTION 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_FIRST_DUP
@ MDBX_FIRST_DUP
Definition: mdbx.h:1548
mdbx_mode_t
mode_t mdbx_mode_t
Definition: mdbx.h:199
mdbx_env_sync_ex
LIBMDBX_API int mdbx_env_sync_ex(MDBX_env *env, bool force, bool nonblock)
Flush the environment data buffers to disk.
mdbx_cursor_renew
LIBMDBX_API int mdbx_cursor_renew(MDBX_txn *txn, MDBX_cursor *cursor)
Renew a cursor handle.
MDBX_LAST_LMDB_ERRCODE
@ MDBX_LAST_LMDB_ERRCODE
Definition: mdbx.h:1738
mdbx_cursor_del
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
MDBX_DBG_ASSERT
@ MDBX_DBG_ASSERT
Definition: mdbx.h:863
MDBX_stat::ms_entries
uint64_t ms_entries
Definition: mdbx.h:2287
mdbx_txn_commit
int mdbx_txn_commit(MDBX_txn *txn)
Commit all the operations of a transaction into the database.
Definition: mdbx.h:3463
MDBX_ENV_DEFAULTS
@ MDBX_ENV_DEFAULTS
Definition: mdbx.h:965
MDBX_envinfo::merge
uint64_t merge
Definition: mdbx.h:2391
MDBX_EIO
@ MDBX_EIO
Definition: mdbx.h:1799
MDBX_INTEGERKEY
@ MDBX_INTEGERKEY
Definition: mdbx.h:1432
mdbx_env_close
int mdbx_env_close(MDBX_env *env)
The shortcut to calling mdbx_env_close_ex() with the dont_sync=false argument.
Definition: mdbx.h:2643
MDBX_EPERM
@ MDBX_EPERM
Definition: mdbx.h:1800
DEFINE_ENUM_FLAG_OPERATORS
#define DEFINE_ENUM_FLAG_OPERATORS(ENUM)
Definition: mdbx.h:555
MDBX_EMULTIVAL
@ MDBX_EMULTIVAL
Definition: mdbx.h:1748
MDBX_GET_BOTH
@ MDBX_GET_BOTH
Definition: mdbx.h:1551
mdbx_version
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
MDBX_envinfo::mi_latter_reader_txnid
uint64_t mi_latter_reader_txnid
Definition: mdbx.h:2339
MDBX_opt_merge_threshold_16dot16_percent
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition: mdbx.h:2066
MDBX_DUPSORT
@ MDBX_DUPSORT
Definition: mdbx.h:1425
MDBX_envinfo::mi_since_reader_check_seconds16dot16
uint32_t mi_since_reader_check_seconds16dot16
Definition: mdbx.h:2375
MDBX_canary
The fours integers markers (aka "canary") associated with the environment.
Definition: mdbx.h:3581
MDBX_ENOSYS
@ MDBX_ENOSYS
Definition: mdbx.h:1798
mdbx_env_get_hsr
MDBX_NOTHROW_PURE_FUNCTION 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_strerror_r
const LIBMDBX_API char * mdbx_strerror_r(int errnum, char *buf, size_t buflen)
Return a string describing a given error code.
mdbx_put_attr
LIBMDBX_API int mdbx_put_attr(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, mdbx_attr_t attr, MDBX_put_flags_t flags)
MDBX_DBI_CREAT
@ MDBX_DBI_CREAT
Definition: mdbx.h:3857
MDBX_opt_sync_period
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition: mdbx.h:1936
MDBX_log_level_t
MDBX_log_level_t
Definition: mdbx.h:797
MDBX_build_info::options
const char * options
Definition: mdbx.h:633
MDBX_version_info::major
uint8_t major
Definition: mdbx.h:614
MDBX_TXN_NOSYNC
@ MDBX_TXN_NOSYNC
Definition: mdbx.h:1405
MDBX_envinfo::spill
uint64_t spill
Definition: mdbx.h:2392
mdbx_is_readahead_reasonable
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...
MDBX_cmp_func
int() MDBX_cmp_func(const MDBX_val *a, const MDBX_val *b) MDBX_CXX17_NOEXCEPT
A callback function used to compare two keys in a database.
Definition: mdbx.h:3641
mdbx_limits_dbsize_min
MDBX_NOTHROW_CONST_FUNCTION 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.
MDBX_CREATE
@ MDBX_CREATE
Definition: mdbx.h:1447
mdbx_txn_commit_ex
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.
MDBX_envinfo::wops
uint64_t wops
Definition: mdbx.h:2394
mdbx_get_sysraminfo
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 ...
MDBX_cursor
struct MDBX_cursor MDBX_cursor
Opaque structure for navigating through a database.
Definition: mdbx.h:722
mdbx_env_get_path
LIBMDBX_API int mdbx_env_get_path(const MDBX_env *env, const char **dest)
Return the path that was used in mdbx_env_open().
mdbx_estimate_range
LIBMDBX_API int mdbx_estimate_range(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *begin_key, MDBX_val *begin_data, MDBX_val *end_key, MDBX_val *end_data, ptrdiff_t *distance_items)
Estimates the size of a range as a number of elements.