lmdb.h(3)

NAME
lmdb.h - Lightning memory-mapped database library.

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

#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
typedef int mdb_filehandle_t
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.

  Functions

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)
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.

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.