Back to index

openldap  2.4.31
Classes | Defines | Typedefs | Enumerations | Functions
mdb.h File Reference

memory-mapped database library More...

#include <sys/types.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MDB_val
 Generic structure used for passing keys and data in and out of the database. More...
struct  MDB_stat
 Statistics for a database in the environment. More...

Defines

#define MDB_VERSION_MAJOR   0
 Library major version.
#define MDB_VERSION_MINOR   9
 Library minor version.
#define MDB_VERSION_PATCH   0
 Library patch version.
#define MDB_VERINT(a, b, c)   (((a) << 24) | ((b) << 16) | (c))
 Combine args a,b,c into a single integer for easy version comparisons.
#define MDB_VERSION_FULL   MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
 The full library version as a single integer.
#define MDB_VERSION_DATE   "September 1, 2011"
 The release date of this library version.
#define MDB_VERSTR(a, b, c, d)   "MDB " #a "." #b "." #c ": (" #d ")"
 A stringifier for the version info.
#define MDB_VERFOO(a, b, c, d)   MDB_VERSTR(a,b,c,d)
 A helper for the stringifier macro.
#define MDB_VERSION_STRING   MDB_VERFOO(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH,MDB_VERSION_DATE)
 The full library version as a C string.
#define MDB_FIXEDMAP   0x01
 mmap at a fixed address
#define MDB_NOSUBDIR   0x02
 no environment directory
#define MDB_NOSYNC   0x10000
 don't fsync after commit
#define MDB_RDONLY   0x20000
 read only
#define MDB_REVERSEKEY   0x02
 use reverse string keys
#define MDB_DUPSORT   0x04
 use sorted duplicates
#define MDB_INTEGERKEY   0x08
 numeric keys in native byte order.
#define MDB_DUPFIXED   0x10
 with MDB_DUPSORT, sorted dup items have fixed size
#define MDB_INTEGERDUP   0x20
 with MDB_DUPSORT, dups are numeric in native byte order
#define MDB_REVERSEDUP   0x40
 with MDB_DUPSORT, use reverse string dups
#define MDB_CREATE   0x40000
 create DB if not already existing
#define MDB_NOOVERWRITE   0x10
 For put: Don't write if the key already exists.
#define MDB_NODUPDATA   0x20
 Only for MDB_DUPSORT
For put: don't write if the key and data pair already exist.
#define MDB_CURRENT   0x40
 For mdb_cursor_put: overwrite the current key/data pair.
#define MDB_RESERVE   0x10000
 For put: Just reserve space for data, don't copy it.
#define MDB_APPEND   0x20000
 Data is being appended, don't split full pages.
#define MDB_MULTIPLE   0x40000
 Store multiple data items in one call.
#define MDB_SUCCESS   0
 Successful result.
#define MDB_KEYEXIST   (-30799)
 key/data pair already exists
#define MDB_NOTFOUND   (-30798)
 key/data pair not found (EOF)
#define MDB_PAGE_NOTFOUND   (-30797)
 Requested page not found - this usually indicates corruption.
#define MDB_CORRUPTED   (-30796)
 Located page was wrong type.
#define MDB_PANIC   (-30795)
 Update of meta page failed, probably I/O error.
#define MDB_VERSION_MISMATCH   (-30794)
 Environment version mismatch.

Typedefs

typedef struct MDB_env
 Opaque structure for a database environment.
typedef struct MDB_txn
 Opaque structure for a transaction handle.
typedef unsigned int MDB_dbi
 A handle for an individual database in the DB environment.
typedef struct MDB_cursor
 Opaque structure for navigating through a database.
typedef struct MDB_val MDB_val
 Generic structure used for passing keys and data in and out of the database.
typedef intMDB_cmp_func )(const MDB_val *a, const MDB_val *b)
 A callback function used to compare two keys in a database.
typedef voidMDB_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 enum MDB_cursor_op MDB_cursor_op
 Cursor Get operations.
typedef struct MDB_stat MDB_stat
 Statistics for a database in the environment.

Enumerations

enum  MDB_cursor_op {
  MDB_FIRST, MDB_FIRST_DUP, MDB_GET_BOTH, MDB_GET_BOTH_RANGE,
  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_RANGE
}
 Cursor Get operations. More...

Functions

char * mdb_version (int *major, int *minor, int *patch)
 Return the mdb 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 MDB environment handle.
int mdb_env_open (MDB_env *env, const char *path, unsigned int flags, mode_t mode)
 Open an environment handle.
int mdb_env_stat (MDB_env *env, MDB_stat *stat)
 Return statistics about the MDB 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_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 for the environment.
int mdb_env_get_maxreaders (MDB_env *env, unsigned int *readers)
 Get the maximum number of threads for the environment.
int mdb_env_set_maxdbs (MDB_env *env, MDB_dbi dbs)
 Set the maximum number of databases for the environment.
int mdb_txn_begin (MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
 Create a transaction for use with the environment.
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_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.
void mdb_close (MDB_env *env, MDB_dbi dbi)
 Close a database handle.
int mdb_drop (MDB_txn *txn, MDB_dbi dbi, int del)
 Delete a database and/or free all its pages.
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.
MDB_txnmdb_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.

Detailed Description

memory-mapped database library

Definition in file mdb.h.