Provided by: lmdb-doc_0.9.23-0ubuntu1_all bug

NAME

       mdb.c - Lightning memory-mapped database library.

SYNOPSIS

       #include <sys/types.h>
       #include <sys/stat.h>
       #include <sys/param.h>
       #include <sys/uio.h>
       #include <sys/mman.h>
       #include <fcntl.h>
       #include <errno.h>
       #include <limits.h>
       #include <stddef.h>
       #include <inttypes.h>
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <time.h>
       #include <unistd.h>
       #include <netinet/in.h>
       #include <resolv.h>
       #include <pthread.h>
       #include <signal.h>
       #include 'lmdb.h'
       #include 'midl.h'

   Data Structures
       struct MDB_rxbody
       struct MDB_reader
       struct MDB_txbody
       struct MDB_txninfo
       struct MDB_page
       struct MDB_node
       struct MDB_db
       struct MDB_meta
       union MDB_metabuf
       struct MDB_dbx
       struct MDB_txn
           Opaque structure for a transaction handle.
       struct MDB_cursor
           Opaque structure for navigating through a database.
       struct MDB_xcursor
       struct MDB_pgstate
       struct MDB_env
           Opaque structure for a database environment.
       struct MDB_ntxn
       struct MDB_name
       struct mdb_copy

   Macros
       #define _GNU_SOURCE   1
       #define MDB_PID_T   pid_t
       #define MDB_THR_T   pthread_t
       #define CACHEFLUSH(addr,  bytes,  cache)
       #define MDB_USE_POSIX_MUTEX   1
       #define VGMEMP_CREATE(h,  r,  z)
       #define VGMEMP_ALLOC(h,  a,  s)
       #define VGMEMP_FREE(h,  a)
       #define VGMEMP_DESTROY(h)
       #define VGMEMP_DEFINED(a,  s)
       #define BYTE_ORDER   __BYTE_ORDER
       #define LITTLE_ENDIAN   __LITTLE_ENDIAN
       #define BIG_ENDIAN   __BIG_ENDIAN
       #define ESECT   __attribute__ ((section('text_env')))
       #define CALL_CONV
       #define MDB_DEVEL   0
       #define mdb_func_   '<mdb_unknown>'
       #define MDB_NO_ROOT   (MDB_LAST_ERRCODE + 10)
       #define MDB_USE_ROBUST   1
       #define THREAD_RET   void *
       #define THREAD_CREATE(thr,  start,  arg)   pthread_create(&thr,NULL,start,arg)
       #define THREAD_FINISH(thr)   pthread_join(thr,NULL)
       #define Z   'z'
       #define MDB_PIDLOCK   1
       #define LOCK_MUTEX0(mutex)   pthread_mutex_lock(mutex)
       #define UNLOCK_MUTEX(mutex)   pthread_mutex_unlock(mutex)
       #define mdb_mutex_consistent(mutex)   pthread_mutex_consistent(mutex)
       #define ErrCode()   errno
       #define HANDLE   int
       #define INVALID_HANDLE_VALUE   (-1)
       #define GET_PAGESIZE(x)   ((x) = sysconf(_SC_PAGE_SIZE))
       #define MNAME_LEN   (sizeof(pthread_mutex_t))
       #define LOCK_MUTEX(rc,  env,  mutex)   ((rc) = LOCK_MUTEX0(mutex))
       #define mdb_mutex_failed(env,  mutex,  rc)   (rc)
       #define MDB_DSYNC   O_SYNC
       #define MDB_FDATASYNC   fdatasync
       #define MDB_MSYNC(addr,  len,  flags)   msync(addr,len,flags)
       #define MS_SYNC   1
       #define MS_ASYNC   0
       #define MDB_DEBUG   0
       #define DPRINTF(args)   ((void) 0)
       #define DPUTS(arg)   DPRINTF(('%s', arg))
       #define DDBI(mc)   (((mc)->mc_flags & C_SUB) ? -(int)(mc)->mc_dbi : (int)(mc)->mc_dbi)
       #define MAX_PAGESIZE   (PAGEBASE ? 0x10000 : 0x8000)
           The maximum size of a database page.
       #define MDB_MINKEYS   2
       #define MDB_MAGIC   0xBEEFC0DE
       #define MDB_DATA_VERSION   ((MDB_DEVEL) ? 999 : 1)
       #define MDB_LOCK_VERSION   1
       #define MDB_MAXKEYSIZE   ((MDB_DEVEL) ? 0 : 511)
           The max size of a key we can write, or 0 for computed max.
       #define ENV_MAXKEY(env)   (MDB_MAXKEYSIZE)
       #define MAXDATASIZE   0xffffffffUL
           The maximum size of a data item.
       #define DKBUF
       #define DKEY(x)   0
       #define P_INVALID   (~(pgno_t)0)
       #define F_ISSET(w,  f)   (((w) & (f)) == (f))
       #define EVEN(n)   (((n) + 1U) & -2) /* sign-extending -2 to match n+1U */
       #define DEFAULT_MAPSIZE   1048576
       #define DEFAULT_READERS   126
       #define CACHELINE   64
       #define mr_txnid   mru.mrx.mrb_txnid
       #define mr_pid   mru.mrx.mrb_pid
       #define mr_tid   mru.mrx.mrb_tid
       #define mti_magic   mt1.mtb.mtb_magic
       #define mti_format   mt1.mtb.mtb_format
       #define mti_rmutex   mt1.mtb.mtb_rmutex
       #define mti_rmname   mt1.mtb.mtb_rmname
       #define mti_txnid   mt1.mtb.mtb_txnid
       #define mti_numreaders   mt1.mtb.mtb_numreaders
       #define mti_wmutex   mt2.mt2_wmutex
       #define MDB_LOCK_FORMAT
       #define mp_pgno   mp_p.p_pgno
       #define mp_next   mp_p.p_next
       #define P_BRANCH   0x01
       #define P_LEAF   0x02
       #define P_OVERFLOW   0x04
       #define P_META   0x08
       #define P_DIRTY   0x10
       #define P_LEAF2   0x20
       #define P_SUBP   0x40
       #define P_LOOSE   0x4000
       #define P_KEEP   0x8000
       #define mp_lower   mp_pb.pb.pb_lower
       #define mp_upper   mp_pb.pb.pb_upper
       #define mp_pages   mp_pb.pb_pages
       #define PAGEHDRSZ   ((unsigned) offsetof(MDB_page, mp_ptrs))
       #define METADATA(p)   ((void *)((char *)(p) + PAGEHDRSZ))
       #define PAGEBASE   ((MDB_DEVEL) ? PAGEHDRSZ : 0)
       #define NUMKEYS(p)   (((p)->mp_lower - (PAGEHDRSZ-PAGEBASE)) >> 1)
       #define SIZELEFT(p)   (indx_t)((p)->mp_upper - (p)->mp_lower)
       #define PAGEFILL(env,  p)
       #define FILL_THRESHOLD   250
       #define IS_LEAF(p)   F_ISSET((p)->mp_flags, P_LEAF)
       #define IS_LEAF2(p)   F_ISSET((p)->mp_flags, P_LEAF2)
       #define IS_BRANCH(p)   F_ISSET((p)->mp_flags, P_BRANCH)
       #define IS_OVERFLOW(p)   F_ISSET((p)->mp_flags, P_OVERFLOW)
       #define IS_SUBP(p)   F_ISSET((p)->mp_flags, P_SUBP)
       #define OVPAGES(size,  psize)   ((PAGEHDRSZ-1 + (size)) / (psize) + 1)
       #define NEXT_LOOSE_PAGE(p)   (*(MDB_page **)((p) + 2))
       #define F_BIGDATA   0x01
       #define F_SUBDATA   0x02
       #define F_DUPDATA   0x04
       #define NODE_ADD_FLAGS   (F_DUPDATA|F_SUBDATA|MDB_RESERVE|MDB_APPEND)
       #define NODESIZE   offsetof(MDB_node, mn_data)
       #define PGNO_TOPWORD   ((pgno_t)-1 > 0xffffffffu ? 32 : 0)
       #define INDXSIZE(k)   (NODESIZE + ((k) == NULL ? 0 : (k)->mv_size))
       #define LEAFSIZE(k,  d)   (NODESIZE + (k)->mv_size + (d)->mv_size)
       #define NODEPTR(p,  i)   ((MDB_node *)((char *)(p) + (p)->mp_ptrs[i] + PAGEBASE))
       #define NODEKEY(node)   (void *)((node)->mn_data)
       #define NODEDATA(node)   (void *)((char *)(node)->mn_data + (node)->mn_ksize)
       #define NODEPGNO(node)
       #define SETPGNO(node,  pgno)
       #define NODEDSZ(node)   ((node)->mn_lo | ((unsigned)(node)->mn_hi << 16))
       #define SETDSZ(node,  size)
       #define NODEKSZ(node)   ((node)->mn_ksize)
       #define COPY_PGNO(dst,  src)
       #define LEAF2KEY(p,  i,  ks)   ((char *)(p) + PAGEHDRSZ + ((i)*(ks)))
       #define MDB_GET_KEY(node,  keyptr)
       #define MDB_GET_KEY2(node,  key)   { key.mv_size = NODEKSZ(node); key.mv_data =
           NODEKEY(node); }
       #define MDB_VALID   0x8000
       #define PERSISTENT_FLAGS   (0xffff & ~(MDB_VALID))
       #define VALID_FLAGS
       #define FREE_DBI   0
       #define MAIN_DBI   1
       #define CORE_DBS   2
       #define NUM_METAS   2
       #define mm_psize   mm_dbs[FREE_DBI].md_pad
       #define mm_flags   mm_dbs[FREE_DBI].md_flags
       #define DB_DIRTY   0x01
       #define DB_STALE   0x02
       #define DB_NEW   0x04
       #define DB_VALID   0x08
       #define DB_USRVALID   0x10
       #define DB_DUPDATA   0x20
       #define MDB_TXN_BEGIN_FLAGS   MDB_RDONLY
       #define MDB_TXN_RDONLY   MDB_RDONLY
       #define MDB_TXN_WRITEMAP   MDB_WRITEMAP
       #define MDB_TXN_FINISHED   0x01
       #define MDB_TXN_ERROR   0x02
       #define MDB_TXN_DIRTY   0x04
       #define MDB_TXN_SPILLS   0x08
       #define MDB_TXN_HAS_CHILD   0x10
       #define MDB_TXN_BLOCKED   (MDB_TXN_FINISHED|MDB_TXN_ERROR|MDB_TXN_HAS_CHILD)
       #define CURSOR_STACK   32
       #define C_INITIALIZED   0x01
       #define C_EOF   0x02
       #define C_SUB   0x04
       #define C_DEL   0x08
       #define C_UNTRACK   0x40
       #define XCURSOR_INITED(mc)   ((mc)->mc_xcursor && ((mc)->mc_xcursor->mx_cursor.mc_flags &
           C_INITIALIZED))
       #define XCURSOR_REFRESH(mc,  top,  mp)
       #define MDB_FATAL_ERROR   0x80000000U
       #define MDB_ENV_ACTIVE   0x20000000U
       #define MDB_ENV_TXKEY   0x10000000U
       #define MDB_FSYNCONLY   0x08000000U
       #define me_pglast   me_pgstate.mf_pglast
       #define me_pghead   me_pgstate.mf_pghead
       #define me_rmutex   me_txns->mti_rmutex
       #define me_wmutex   me_txns->mti_wmutex
       #define MDB_COMMIT_PAGES   64
       #define MAX_WRITE   (0x40000000U >> (sizeof(ssize_t) == 4))
       #define TXN_DBI_EXIST(txn,  dbi,  validity)   ((txn) && (dbi)<(txn)->mt_numdbs &&
           ((txn)->mt_dbflags[dbi] & (validity)))
       #define TXN_DBI_CHANGED(txn,  dbi)   ((txn)->mt_dbiseqs[dbi] !=
           (txn)->mt_env->me_dbiseqs[dbi])
       #define MDB_END_NAMES
       #define MDB_END_OPMASK   0x0F
       #define MDB_END_UPDATE   0x10
       #define MDB_END_FREE   0x20
       #define MDB_END_SLOT   MDB_NOTLS
       #define MDB_PS_MODIFY   1
       #define MDB_PS_ROOTONLY   2
       #define MDB_PS_FIRST   4
       #define MDB_PS_LAST   8
       #define MDB_SPLIT_REPLACE   MDB_APPENDDUP
       #define mdb_env_close0(env,  excl)   mdb_env_close1(env)
       #define mdb_cmp_clong   mdb_cmp_cint
       #define mdb_cassert(mc,  expr)   mdb_assert0((mc)->mc_txn->mt_env, expr, #expr)
       #define mdb_tassert(txn,  expr)   mdb_assert0((txn)->mt_env, expr, #expr)
       #define mdb_eassert(env,  expr)   mdb_assert0(env, expr, #expr)
       #define mdb_assert0(env,  expr,  expr_txt)
       #define DO_PWRITE(rc,  fd,  ptr,  size,  len,  pos)
       #define MDB_NAME(str)   str
       #define mdb_name_cpy   strcpy
       #define MDB_SUFFLEN   9
       #define mdb_fname_destroy(fname)   do { if ((fname).mn_alloced) free((fname).mn_val); }
           while (0)
       #define MDB_CLOEXEC   0
       #define MDB_ERRCODE_ROFS   EROFS
       #define CHANGEABLE   (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC|MDB_NOMEMINIT)
       #define CHANGELESS
       #define MDB_NOSPILL   0x8000
       #define WITH_CURSOR_TRACKING(mn,  act)
       #define MDB_WBUF   (1024*1024)
       #define MDB_EOF   0x10
       #define DO_WRITE(rc,  fd,  ptr,  w2,  len)   len = write(fd, ptr, w2); rc = (len >= 0)
       #define DO_WRITE(rc,  fd,  ptr,  w2,  len)   len = write(fd, ptr, w2); rc = (len >= 0)

   Typedefs
       typedef pthread_mutex_t mdb_mutex_t[1]
       typedef pthread_mutex_t * mdb_mutexref_t
       typedef MDB_ID pgno_t
       typedef MDB_ID txnid_t
       typedef uint16_t indx_t
       typedef char mdb_nchar_t

   Enumerations
       enum { MDB_END_COMMITTED, MDB_END_EMPTY_COMMIT, MDB_END_ABORT, MDB_END_RESET,
           MDB_END_RESET_TMP, MDB_END_FAIL_BEGIN, MDB_END_FAIL_BEGINCHILD }
       enum Pidlock_op { Pidset = F_SETLK, Pidcheck = F_GETLK }
       enum mdb_fopen_type { MDB_O_RDONLY = O_RDONLY, MDB_O_RDWR = O_RDWR |O_CREAT, MDB_O_META =
           O_WRONLY|MDB_DSYNC |MDB_CLOEXEC, MDB_O_COPY = O_WRONLY|O_CREAT|O_EXCL|MDB_CLOEXEC,
           MDB_O_MASK = MDB_O_RDWR|MDB_CLOEXEC | MDB_O_RDONLY|MDB_O_META|MDB_O_COPY, MDB_O_LOCKS
           = MDB_O_RDWR|MDB_CLOEXEC | ((MDB_O_MASK+1) & ~MDB_O_MASK) }

   Functions
       static int mdb_page_alloc (MDB_cursor *mc, int num, MDB_page **mp)
       static int mdb_page_new (MDB_cursor *mc, uint32_t flags, int num, MDB_page **mp)
       static int mdb_page_touch (MDB_cursor *mc)
       static void mdb_txn_end (MDB_txn *txn, unsigned mode)
       static int mdb_page_get (MDB_cursor *mc, pgno_t pgno, MDB_page **mp, int *lvl)
       static int mdb_page_search_root (MDB_cursor *mc, MDB_val *key, int modify)
       static int mdb_page_search (MDB_cursor *mc, MDB_val *key, int flags)
       static int mdb_page_merge (MDB_cursor *csrc, MDB_cursor *cdst)
       static int mdb_page_split (MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t
           newpgno, unsigned int nflags)
       static int mdb_env_read_header (MDB_env *env, MDB_meta *meta)
       static MDB_meta * mdb_env_pick_meta (const MDB_env *env)
       static int mdb_env_write_meta (MDB_txn *txn)
       static void mdb_env_close0 (MDB_env *env, int excl)
       static MDB_node * mdb_node_search (MDB_cursor *mc, MDB_val *key, int *exactp)
       static int mdb_node_add (MDB_cursor *mc, indx_t indx, MDB_val *key, MDB_val *data, pgno_t
           pgno, unsigned int flags)
       static void mdb_node_del (MDB_cursor *mc, int ksize)
       static void mdb_node_shrink (MDB_page *mp, indx_t indx)
       static int mdb_node_move (MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
       static int mdb_node_read (MDB_cursor *mc, MDB_node *leaf, MDB_val *data)
       static size_t mdb_leaf_size (MDB_env *env, MDB_val *key, MDB_val *data)
       static size_t mdb_branch_size (MDB_env *env, MDB_val *key)
       static int mdb_rebalance (MDB_cursor *mc)
       static int mdb_update_key (MDB_cursor *mc, MDB_val *key)
       static void mdb_cursor_pop (MDB_cursor *mc)
       static int mdb_cursor_push (MDB_cursor *mc, MDB_page *mp)
       static int mdb_cursor_del0 (MDB_cursor *mc)
       static int mdb_del0 (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, unsigned
           flags)
       static int mdb_cursor_sibling (MDB_cursor *mc, int move_right)
       static int mdb_cursor_next (MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
       static int mdb_cursor_prev (MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
       static int mdb_cursor_set (MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op,
           int *exactp)
       static int mdb_cursor_first (MDB_cursor *mc, MDB_val *key, MDB_val *data)
       static int mdb_cursor_last (MDB_cursor *mc, MDB_val *key, MDB_val *data)
       static void mdb_cursor_init (MDB_cursor *mc, MDB_txn *txn, MDB_dbi dbi, MDB_xcursor *mx)
       static void mdb_xcursor_init0 (MDB_cursor *mc)
       static void mdb_xcursor_init1 (MDB_cursor *mc, MDB_node *node)
       static void mdb_xcursor_init2 (MDB_cursor *mc, MDB_xcursor *src_mx, int force)
       static int mdb_drop0 (MDB_cursor *mc, int subs)
       static void mdb_default_cmp (MDB_txn *txn, MDB_dbi dbi)
       static int mdb_reader_check0 (MDB_env *env, int rlocked, int *dead)
       char *ESECT 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.
       static void ESECT mdb_assert_fail (MDB_env *env, const char *expr_txt, const char *func,
           const char *file, int line)
       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.
       static MDB_page * mdb_page_malloc (MDB_txn *txn, unsigned num)
       static void mdb_page_free (MDB_env *env, MDB_page *mp)
       static void mdb_dpage_free (MDB_env *env, MDB_page *dp)
       static void mdb_dlist_free (MDB_txn *txn)
       static int mdb_page_loose (MDB_cursor *mc, MDB_page *mp)
       static int mdb_pages_xkeep (MDB_cursor *mc, unsigned pflags, int all)
       static int mdb_page_flush (MDB_txn *txn, int keep)
       static int mdb_page_spill (MDB_cursor *m0, MDB_val *key, MDB_val *data)
       static txnid_t mdb_find_oldest (MDB_txn *txn)
       static void mdb_page_dirty (MDB_txn *txn, MDB_page *mp)
       static void mdb_page_copy (MDB_page *dst, MDB_page *src, unsigned int psize)
       static int mdb_page_unspill (MDB_txn *txn, MDB_page *mp, MDB_page **ret)
       int mdb_env_sync (MDB_env *env, int force)
           Flush the data buffers to disk.
       static int mdb_cursor_shadow (MDB_txn *src, MDB_txn *dst)
       static void mdb_cursors_close (MDB_txn *txn, unsigned merge)
       static int mdb_reader_pid (MDB_env *env, enum Pidlock_op op, MDB_PID_T pid)
       static int mdb_txn_renew0 (MDB_txn *txn)
       int mdb_txn_renew (MDB_txn *txn)
           Renew a read-only transaction.
       int mdb_txn_begin (MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **ret)
           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.
       static void mdb_dbis_update (MDB_txn *txn, int keep)
       void mdb_txn_reset (MDB_txn *txn)
           Reset a read-only transaction.
       void mdb_txn_abort (MDB_txn *txn)
           Abandon all the operations of the transaction instead of saving them.
       static int mdb_freelist_save (MDB_txn *txn)
       int mdb_txn_commit (MDB_txn *txn)
           Commit all the operations of a transaction into the database.
       static void ESECT mdb_env_init_meta0 (MDB_env *env, MDB_meta *meta)
       static int ESECT mdb_env_init_meta (MDB_env *env, MDB_meta *meta)
       int ESECT mdb_env_create (MDB_env **env)
           Create an LMDB environment handle.
       static int ESECT mdb_env_map (MDB_env *env, void *addr)
       int ESECT mdb_env_set_mapsize (MDB_env *env, size_t size)
           Set the size of the memory map to use for this environment.
       int ESECT mdb_env_set_maxdbs (MDB_env *env, MDB_dbi dbs)
           Set the maximum number of named databases for the environment.
       int ESECT mdb_env_set_maxreaders (MDB_env *env, unsigned int readers)
           Set the maximum number of threads/reader slots for the environment.
       int ESECT mdb_env_get_maxreaders (MDB_env *env, unsigned int *readers)
           Get the maximum number of threads/reader slots for the environment.
       static int ESECT mdb_fsize (HANDLE fd, size_t *size)
       static int ESECT mdb_fname_init (const char *path, unsigned envflags, MDB_name *fname)
       static int ESECT mdb_fopen (const MDB_env *env, MDB_name *fname, enum mdb_fopen_type
           which, mdb_mode_t mode, HANDLE *res)
       static int ESECT mdb_env_open2 (MDB_env *env)
       static void mdb_env_reader_dest (void *ptr)
       static int ESECT mdb_env_share_locks (MDB_env *env, int *excl)
       static int ESECT mdb_env_excl_lock (MDB_env *env, int *excl)
       static int ESECT mdb_env_setup_locks (MDB_env *env, MDB_name *fname, int mode, int *excl)
       int ESECT mdb_env_open (MDB_env *env, const char *path, unsigned int flags, mdb_mode_t
           mode)
           Open an environment handle.
       void ESECT mdb_env_close (MDB_env *env)
           Close the environment and release the memory map.
       static int mdb_cmp_long (const MDB_val *a, const MDB_val *b)
       static int mdb_cmp_int (const MDB_val *a, const MDB_val *b)
       static int mdb_cmp_cint (const MDB_val *a, const MDB_val *b)
       static int mdb_cmp_memn (const MDB_val *a, const MDB_val *b)
       static int mdb_cmp_memnr (const MDB_val *a, const MDB_val *b)
       static int mdb_page_search_lowest (MDB_cursor *mc)
       static int mdb_ovpage_free (MDB_cursor *mc, MDB_page *mp)
       int mdb_get (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data)
           Get items from a database.
       int mdb_cursor_get (MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
           Retrieve by cursor.
       static int mdb_cursor_touch (MDB_cursor *mc)
       int mdb_cursor_put (MDB_cursor *mc, MDB_val *key, MDB_val *data, unsigned int flags)
           Store by cursor.
       int mdb_cursor_del (MDB_cursor *mc, unsigned int flags)
           Delete current key/data pair.
       int mdb_cursor_open (MDB_txn *txn, MDB_dbi dbi, MDB_cursor **ret)
           Create a cursor handle.
       int mdb_cursor_renew (MDB_txn *txn, MDB_cursor *mc)
           Renew a cursor handle.
       int mdb_cursor_count (MDB_cursor *mc, size_t *countp)
           Return count of duplicates for current key.
       void mdb_cursor_close (MDB_cursor *mc)
           Close a cursor handle.
       MDB_txn * mdb_cursor_txn (MDB_cursor *mc)
           Return the cursor's transaction handle.
       MDB_dbi mdb_cursor_dbi (MDB_cursor *mc)
           Return the cursor's database handle.
       static void mdb_cursor_copy (const MDB_cursor *csrc, MDB_cursor *cdst)
       int mdb_del (MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data)
           Delete 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.
       static THREAD_RET ESECT CALL_CONV mdb_env_copythr (void *arg)
       static int ESECT mdb_env_cthr_toggle (mdb_copy *my, int adjust)
       static int ESECT mdb_env_cwalk (mdb_copy *my, pgno_t *pg, int flags)
       static int ESECT mdb_env_copyfd1 (MDB_env *env, HANDLE fd)
       static int ESECT mdb_env_copyfd0 (MDB_env *env, HANDLE fd)
       int ESECT mdb_env_copyfd2 (MDB_env *env, HANDLE fd, unsigned int flags)
       int ESECT mdb_env_copyfd (MDB_env *env, HANDLE fd)
       int ESECT mdb_env_copy2 (MDB_env *env, const char *path, unsigned int flags)
           Copy an LMDB environment to the specified path, with options.
       int ESECT mdb_env_copy (MDB_env *env, const char *path)
           Copy an LMDB environment to the specified path.
       int ESECT mdb_env_set_flags (MDB_env *env, unsigned int flag, int onoff)
           Set environment flags.
       int ESECT mdb_env_get_flags (MDB_env *env, unsigned int *arg)
           Get environment flags.
       int ESECT mdb_env_set_userctx (MDB_env *env, void *ctx)
           Set application information associated with the MDB_env.
       void *ESECT mdb_env_get_userctx (MDB_env *env)
           Get the application information associated with the MDB_env.
       int ESECT mdb_env_set_assert (MDB_env *env, MDB_assert_func *func)
       int ESECT mdb_env_get_path (MDB_env *env, const char **arg)
           Return the path that was used in mdb_env_open().
       int ESECT mdb_env_get_fd (MDB_env *env, mdb_filehandle_t *arg)
           Return the filedescriptor for the given environment.
       static int ESECT mdb_stat0 (MDB_env *env, MDB_db *db, MDB_stat *arg)
       int ESECT mdb_env_stat (MDB_env *env, MDB_stat *arg)
           Return statistics about the LMDB environment.
       int ESECT mdb_env_info (MDB_env *env, MDB_envinfo *arg)
           Return information about the LMDB environment.
       int mdb_dbi_open (MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
           Open a database in the environment.
       int ESECT mdb_stat (MDB_txn *txn, MDB_dbi dbi, MDB_stat *arg)
           Retrieve statistics for a database.
       void mdb_dbi_close (MDB_env *env, MDB_dbi dbi)
           Close a database handle. Normally unnecessary. Use with care:
       int mdb_dbi_flags (MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
           Retrieve the DB flags for a database handle.
       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 ESECT mdb_env_get_maxkeysize (MDB_env *env)
           Get the maximum size of keys and MDB_DUPSORT data we can write.
       int ESECT mdb_reader_list (MDB_env *env, MDB_msg_func *func, void *ctx)
           Dump the entries in the reader lock table.
       static int ESECT mdb_pid_insert (MDB_PID_T *ids, MDB_PID_T pid)
       int ESECT mdb_reader_check (MDB_env *env, int *dead)
           Check for stale entries in the reader lock table.

   Variables
       static char *const mdb_errstr []
       static const mdb_nchar_t *const mdb_suffixes [2][2]

Detailed Description

       Lightning memory-mapped database library.

       A Btree-based database management library modeled loosely on the BerkeleyDB API, but much
       simplified.

Macro Definition Documentation

   #define ESECT   __attribute__ ((section('text_env')))
       Put infrequently used env functions in separate section

   #define mr_txnid   mru.mrx.mrb_txnid
       shorthand for mrb_txnid

   #define mm_psize   mm_dbs[FREE_DBI].md_pad
       The size of pages used in this DB

   #define mm_flags   mm_dbs[FREE_DBI].md_flags
       Any persistent environment flags. Environment Flags

   #define MDB_FATAL_ERROR   0x80000000U
       Failed to update the meta page. Probably an I/O error.

   #define MDB_ENV_ACTIVE   0x20000000U
       Some fields are initialized.

   #define MDB_ENV_TXKEY   0x10000000U
       me_txkey is set

   #define MDB_FSYNCONLY   0x08000000U
       fdatasync is unreliable

   #define me_rmutex   me_txns->mti_rmutex
       Shared reader lock

   #define me_wmutex   me_txns->mti_wmutex
       Shared writer lock

   #define DO_PWRITE(rc, fd, ptr, size, len, pos)
       Value:

       do {     len = pwrite(fd, ptr, size, pos);       if (len == -1 && ErrCode() == EINTR) continue;     rc = (len >= 0); break; } while(1)

Author

       Generated automatically by Doxygen for LMDB from the source code.