lmdb.h(3)

πŸ“¦
version 0.9.35 Β· 4 versions
, in ubuntu stonking

πŸ’– NAME

lmdb.h β€” Lightning memory-mapped database library.

This is the page for lmdb.h(3), section 3 of the Library Functions Manual. Bestie, we're about to vibe with LMDB's public header. No cap.


✨ SYNOPSIS

#include <sys/types.h>

🧸 Data Structures

  • struct MDB_val β€” Generic structure used for passing keys and data in and out of the database.
  • struct MDB_stat β€” Statistics for a database in the environment.
  • struct MDB_envinfo β€” Information about the environment.

🌈 Macros

Okay so here's the entire macro wall, and I mean entire. Every define, every value, exactly as the header says. Don't skip a single one, fr fr.

#define MDB_VERSION_MAJOR   0
#define MDB_VERSION_MINOR   9
#define MDB_VERSION_PATCH   35
#define MDB_VERINT(a,  b,  c)
#define MDB_VERSION_FULL
    MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
#define MDB_VERSION_DATE   'Jan 27, 2026'
#define MDB_VERSTR(a,  b,  c,  d)
#define MDB_VERFOO(a,  b,  c,  d)
#define MDB_VERSION_STRING
    MDB_VERFOO(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH,MDB_VERSION_DATE)
#define MDB_FIXEDMAP   0x01
#define MDB_NOSUBDIR   0x4000
#define MDB_NOSYNC   0x10000
#define MDB_RDONLY   0x20000
#define MDB_NOMETASYNC   0x40000
#define MDB_WRITEMAP   0x80000
#define MDB_MAPASYNC   0x100000
#define MDB_NOTLS   0x200000
#define MDB_NOLOCK   0x400000
#define MDB_NORDAHEAD   0x800000
#define MDB_NOMEMINIT   0x1000000
#define MDB_REVERSEKEY   0x02
#define MDB_DUPSORT   0x04
#define MDB_INTEGERKEY   0x08
#define MDB_DUPFIXED   0x10
#define MDB_INTEGERDUP   0x20
#define MDB_REVERSEDUP   0x40
#define MDB_CREATE   0x40000
#define MDB_NOOVERWRITE   0x10
#define MDB_NODUPDATA   0x20
#define MDB_CURRENT   0x40
#define MDB_RESERVE   0x10000
#define MDB_APPEND   0x20000
#define MDB_APPENDDUP   0x40000
#define MDB_MULTIPLE   0x80000
#define MDB_CP_COMPACT   0x01
#define MDB_SUCCESS   0
#define MDB_KEYEXIST   (-30799)
#define MDB_NOTFOUND   (-30798)
#define MDB_PAGE_NOTFOUND   (-30797)
#define MDB_CORRUPTED   (-30796)
#define MDB_PANIC   (-30795)
#define MDB_VERSION_MISMATCH   (-30794)
#define MDB_INVALID   (-30793)
#define MDB_MAP_FULL   (-30792)
#define MDB_DBS_FULL   (-30791)
#define MDB_READERS_FULL   (-30790)
#define MDB_TLS_FULL   (-30789)
#define MDB_TXN_FULL   (-30788)
#define MDB_CURSOR_FULL   (-30787)
#define MDB_PAGE_FULL   (-30786)
#define MDB_MAP_RESIZED   (-30785)
#define MDB_INCOMPATIBLE   (-30784)
#define MDB_BAD_RSLOT   (-30783)
#define MDB_BAD_TXN   (-30782)
#define MDB_BAD_VALSIZE   (-30781)
#define MDB_BAD_DBI   (-30780)
#define MDB_LAST_ERRCODE   MDB_BAD_DBI
#define mdb_open(txn,  name,  flags,  dbi)
#define mdb_close(env,  dbi)

πŸ¦‹ Typedefs

  • typedef mode_t mdb_mode_t β€” Unix permissions for creating files, or dummy definition for Windows.
  • typedef int mdb_filehandle_t β€” An abstraction for a file handle. On POSIX systems file handles are small integers. On Windows they're opaque pointers.
  • typedef unsigned int MDB_dbi β€” A handle for an individual database in the DB environment.
  • typedef int MDB_cmp_func(const MDB_val *a, const MDB_val *b) β€” A callback function used to compare two keys in a database.
  • typedef void MDB_rel_func(MDB_val *item, void *oldptr, void *newptr, void *relctx) β€” A callback function used to relocate a position-dependent data item in a fixed-address database.
  • typedef void MDB_assert_func(MDB_env *env, const char *msg) β€” A callback function for most LMDB assert() failures, called before printing the message and aborting.
  • typedef int MDB_msg_func(const char *msg, void *ctx) β€” A callback function used to print a message from the library.

✨ Enumerations

enum MDB_cursor_op { MDB_FIRST, MDB_FIRST_DUP, MDB_GET_BOTH,
    MDB_GET_BOTH_RANGE, MDB_GET_CURRENT, MDB_GET_MULTIPLE, MDB_LAST,
    MDB_LAST_DUP, MDB_NEXT, MDB_NEXT_DUP, MDB_NEXT_MULTIPLE,
    MDB_NEXT_NODUP, MDB_PREV, MDB_PREV_DUP, MDB_PREV_NODUP, MDB_SET,
    MDB_SET_KEY, MDB_SET_RANGE, MDB_PREV_MULTIPLE }

Cursor Get operations. That's the whole enum, bestie. Every op is in there.

πŸ’… Functions

Okay, this is the function lineup. Every prototype, every one-liner, exactly as printed. Slay.

  • char * mdb_version (int *major, int *minor, int *patch) β€” Return the LMDB library version information.
  • char * mdb_strerror (int err) β€” Return a string describing a given error code.
  • int mdb_env_create (MDB_env **env) β€” Create an LMDB environment handle.
  • int mdb_env_open (MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode) β€” Open an environment handle.
  • int mdb_env_copy (MDB_env *env, const char *path) β€” Copy an LMDB environment to the specified path.
  • int mdb_env_copyfd (MDB_env *env, mdb_filehandle_t fd) β€” Copy an LMDB environment to the specified file descriptor.
  • int mdb_env_copy2 (MDB_env *env, const char *path, unsigned int flags) β€” Copy an LMDB environment to the specified path, with options.
  • int mdb_env_copyfd2 (MDB_env *env, mdb_filehandle_t fd, unsigned int flags) β€” Copy an LMDB environment to the specified file descriptor, with options.
  • int mdb_env_stat (MDB_env *env, MDB_stat *stat) β€” Return statistics about the LMDB environment.
  • int mdb_env_info (MDB_env *env, MDB_envinfo *stat) β€” Return information about the LMDB environment.
  • int mdb_env_sync (MDB_env *env, int force) β€” Flush the data buffers to disk.
  • void mdb_env_close (MDB_env *env) β€” Close the environment and release the memory map.
  • int mdb_env_set_flags (MDB_env *env, unsigned int flags, int onoff) β€” Set environment flags.
  • int mdb_env_get_flags (MDB_env *env, unsigned int *flags) β€” Get environment flags.
  • int mdb_env_get_path (MDB_env *env, const char **path) β€” Return the path that was used in mdb_env_open().
  • int mdb_env_get_fd (MDB_env *env, mdb_filehandle_t *fd) β€” Return the filedescriptor for the given environment.
  • int mdb_env_set_mapsize (MDB_env *env, size_t size) β€” Set the size of the memory map to use for this environment.
  • int mdb_env_set_maxreaders (MDB_env *env, unsigned int readers) β€” Set the maximum number of threads/reader slots for the environment.
  • int mdb_env_get_maxreaders (MDB_env *env, unsigned int *readers) β€” Get the maximum number of threads/reader slots for the environment.
  • int mdb_env_set_maxdbs (MDB_env *env, MDB_dbi dbs) β€” Set the maximum number of named databases for the environment.
  • int mdb_env_get_maxkeysize (MDB_env *env) β€” Get the maximum size of keys and MDB_DUPSORT data we can write.
  • int mdb_env_set_userctx (MDB_env *env, void *ctx) β€” Set application information associated with the MDB_env.
  • void * mdb_env_get_userctx (MDB_env *env) β€” Get the application information associated with the MDB_env.
  • int mdb_env_set_assert (MDB_env *env, MDB_assert_func *func) β€” (no description in the page, just the prototype)
  • int mdb_txn_begin (MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn) β€” Create a transaction for use with the environment.
  • MDB_env * mdb_txn_env (MDB_txn *txn) β€” Returns the transaction's MDB_env.
  • size_t mdb_txn_id (MDB_txn *txn) β€” Return the transaction's ID.
  • int mdb_txn_commit (MDB_txn *txn) β€” Commit all the operations of a transaction into the database.
  • void mdb_txn_abort (MDB_txn *txn) β€” Abandon all the operations of the transaction instead of saving them.
  • void mdb_txn_reset (MDB_txn *txn) β€” Reset a read-only transaction.
  • int mdb_txn_renew (MDB_txn *txn) β€” Renew a read-only transaction.
  • int mdb_dbi_open (MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi) β€” Open a database in the environment.
  • int mdb_stat (MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat) β€” Retrieve statistics for a database.
  • int mdb_dbi_flags (MDB_txn *txn, MDB_dbi dbi, unsigned int *flags) β€” Retrieve the DB flags for a database handle.
  • void mdb_dbi_close (MDB_env *env, MDB_dbi dbi) β€” Close a database handle. Normally unnecessary. Use with care:
  • int mdb_drop (MDB_txn *txn, MDB_dbi dbi, int del) β€” Empty or delete+close a database.
  • int mdb_set_compare (MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp) β€” Set a custom key comparison function for a database.
  • int mdb_set_dupsort (MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp) β€” Set a custom data comparison function for a MDB_DUPSORT database.
  • int mdb_set_relfunc (MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel) β€” Set a relocation function for a MDB_FIXEDMAP database.
  • int mdb_set_relctx (MDB_txn *txn, MDB_dbi dbi, void *ctx) β€” Set a context pointer for a MDB_FIXEDMAP database's relocation function.
  • int mdb_get (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data) β€” Get items from a database.
  • int mdb_put (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, unsigned int flags) β€” Store items into a database.
  • int mdb_del (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data) β€” Delete items from a database.
  • int mdb_cursor_open (MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor) β€” Create a cursor handle.
  • void mdb_cursor_close (MDB_cursor *cursor) β€” Close a cursor handle.
  • int mdb_cursor_renew (MDB_txn *txn, MDB_cursor *cursor) β€” Renew a cursor handle.
  • MDB_txn * mdb_cursor_txn (MDB_cursor *cursor) β€” Return the cursor's transaction handle.
  • MDB_dbi mdb_cursor_dbi (MDB_cursor *cursor) β€” Return the cursor's database handle.
  • int mdb_cursor_get (MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op) β€” Retrieve by cursor.
  • int mdb_cursor_put (MDB_cursor *cursor, MDB_val *key, MDB_val *data, unsigned int flags) β€” Store by cursor.
  • int mdb_cursor_del (MDB_cursor *cursor, unsigned int flags) β€” Delete current key/data pair.
  • int mdb_cursor_count (MDB_cursor *cursor, size_t *countp) β€” Return count of duplicates for current key.
  • int mdb_cmp (MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b) β€” Compare two data items according to a particular database.
  • int mdb_dcmp (MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b) β€” Compare two data items according to a particular database.
  • int mdb_reader_list (MDB_env *env, MDB_msg_func *func, void *ctx) β€” Dump the entries in the reader lock table.
  • int mdb_reader_check (MDB_env *env, int *dead) β€” Check for stale entries in the reader lock table.

πŸ“š Detailed Description

Lightning memory-mapped database library. That's the whole detailed description, bestie. Short and iconic.


🧡 Typedef Documentation

  • typedef mode_t mdb_mode_t Unix permissions for creating files, or dummy definition for Windows.
  • typedef int mdb_filehandle_t An abstraction for a file handle. On POSIX systems file handles are small integers. On Windows they're opaque pointers.

✍️ Author

Generated automatically by Doxygen for LMDB from the source code.

So yeah, this page was auto-generated by Doxygen for LMDB from the source code. Not a human author, just the tool doing its thing πŸ’….


This page is lmdb.h(3) from the LMDB library, version date 'Jan 27, 2026', and the footer is LMDB / lmdb.h(3). Bye bestie, go map some memory πŸ’–βœ¨

πŸ“¦ where this page comes from