169 #include <sys/types.h> 185 # define MDB_FMT_Z "I" 187 # define MDB_FMT_Z "z" 197 # define MDB_SIZE_MAX SIZE_MAX 199 # define MDB_PRIy(t) MDB_FMT_Z #t 201 # define MDB_SCNy(t) MDB_FMT_Z #t 204 # define MDB_SIZE_MAX UINT64_MAX 205 # define MDB_PRIy(t) PRI##t##64 206 # define MDB_SCNy(t) SCN##t##64 207 # define mdb_env_create mdb_env_create_vl32 228 #define MDB_VERSION_MAJOR 0 230 #define MDB_VERSION_MINOR 9 232 #define MDB_VERSION_PATCH 70 235 #define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c)) 238 #define MDB_VERSION_FULL \ 239 MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH) 242 #define MDB_VERSION_DATE "December 19, 2015" 245 #define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")" 248 #define MDB_VERFOO(a,b,c,d) MDB_VERSTR(a,b,c,d) 251 #define MDB_VERSION_STRING \ 252 MDB_VERFOO(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH,MDB_VERSION_DATE) 314 #define MDB_FIXEDMAP 0x01 316 #define MDB_NOSUBDIR 0x4000 318 #define MDB_NOSYNC 0x10000 320 #define MDB_RDONLY 0x20000 322 #define MDB_NOMETASYNC 0x40000 324 #define MDB_WRITEMAP 0x80000 326 #define MDB_MAPASYNC 0x100000 328 #define MDB_NOTLS 0x200000 330 #define MDB_NOLOCK 0x400000 332 #define MDB_NORDAHEAD 0x800000 334 #define MDB_NOMEMINIT 0x1000000 336 #define MDB_PREVSNAPSHOT 0x2000000 343 #define MDB_REVERSEKEY 0x02 345 #define MDB_DUPSORT 0x04 349 #define MDB_INTEGERKEY 0x08 351 #define MDB_DUPFIXED 0x10 353 #define MDB_INTEGERDUP 0x20 355 #define MDB_REVERSEDUP 0x40 357 #define MDB_CREATE 0x40000 364 #define MDB_NOOVERWRITE 0x10 369 #define MDB_NODUPDATA 0x20 371 #define MDB_CURRENT 0x40 375 #define MDB_RESERVE 0x10000 377 #define MDB_APPEND 0x20000 379 #define MDB_APPENDDUP 0x40000 381 #define MDB_MULTIPLE 0x80000 390 #define MDB_CP_COMPACT 0x01 435 #define MDB_SUCCESS 0 437 #define MDB_KEYEXIST (-30799) 439 #define MDB_NOTFOUND (-30798) 441 #define MDB_PAGE_NOTFOUND (-30797) 443 #define MDB_CORRUPTED (-30796) 445 #define MDB_PANIC (-30795) 447 #define MDB_VERSION_MISMATCH (-30794) 449 #define MDB_INVALID (-30793) 451 #define MDB_MAP_FULL (-30792) 453 #define MDB_DBS_FULL (-30791) 455 #define MDB_READERS_FULL (-30790) 457 #define MDB_TLS_FULL (-30789) 459 #define MDB_TXN_FULL (-30788) 461 #define MDB_CURSOR_FULL (-30787) 463 #define MDB_PAGE_FULL (-30786) 465 #define MDB_MAP_RESIZED (-30785) 474 #define MDB_INCOMPATIBLE (-30784) 476 #define MDB_BAD_RSLOT (-30783) 478 #define MDB_BAD_TXN (-30782) 480 #define MDB_BAD_VALSIZE (-30781) 482 #define MDB_BAD_DBI (-30780) 484 #define MDB_PROBLEM (-30779) 486 #define MDB_LAST_ERRCODE MDB_PROBLEM 517 char *
mdb_version(
int *major,
int *minor,
int *patch);
1100 #define mdb_open(txn,name,flags,dbi) mdb_dbi_open(txn,name,flags,dbi) 1102 #define mdb_close(env,dbi) mdb_dbi_close(env,dbi) 1383 unsigned int flags);
1553 unsigned int flags);
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_env_set_mapsize(MDB_env *env, mdb_size_t size)
Set the size of the memory map to use for this environment.
void mdb_cursor_close(MDB_cursor *cursor)
Close a cursor handle.
int mdb_env_set_assert(MDB_env *env, MDB_assert_func *func)
int mdb_del(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data)
Delete items from a database.
int mdb_cursor_count(MDB_cursor *cursor, mdb_size_t *countp)
Return count of duplicates for current key.
int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Open a database in the environment.
char * mdb_version(int *major, int *minor, int *patch)
Return the LMDB library version information.
int mdb_txn_commit(MDB_txn *txn)
Commit all the operations of a transaction into the database.
int mdb_cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data, unsigned int flags)
Store by cursor.
int mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat)
Retrieve statistics for a database.
unsigned int me_numreaders
void mdb_dbi_close(MDB_env *env, MDB_dbi dbi)
Close a database handle. Normally unnecessary. Use with care:
void * mdb_env_get_userctx(MDB_env *env)
Get the application information associated with the MDB_env.
struct MDB_envinfo MDB_envinfo
Information about the environment.
int() MDB_cmp_func(const MDB_val *a, const MDB_val *b)
A callback function used to compare two keys in a database.
int mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers)
Get the maximum number of threads/reader slots for the environment.
MDB_txn * mdb_cursor_txn(MDB_cursor *cursor)
Return the cursor's transaction handle.
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_env_info(MDB_env *env, MDB_envinfo *stat)
Return information about the LMDB environment.
int mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs)
Set the maximum number of named databases for the environment.
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...
int mdb_env_get_maxkeysize(MDB_env *env)
Get the maximum size of keys and MDB_DUPSORT data we can write.
struct MDB_env MDB_env
Opaque structure for a database environment.
mdb_size_t ms_branch_pages
MDB_env * mdb_txn_env(MDB_txn *txn)
Returns the transaction's MDB_env.
struct MDB_val MDB_val
Generic structure used for passing keys and data in and out of the database.
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...
unsigned int me_maxreaders
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.
MDB_dbi mdb_cursor_dbi(MDB_cursor *cursor)
Return the cursor's database handle.
int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
Dump the entries in the reader lock table.
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
int mdb_env_copyfd(MDB_env *env, mdb_filehandle_t fd)
Copy an LMDB environment to the specified file descriptor.
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_flags(MDB_env *env, unsigned int *flags)
Get environment flags.
int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del)
Empty or delete+close a database.
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_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode)
Open an environment handle.
Statistics for a database in the environment.
Information about the environment.
int mdb_env_copy(MDB_env *env, const char *path)
Copy an LMDB environment to the specified path.
void mdb_txn_reset(MDB_txn *txn)
Reset a read-only transaction.
int mdb_dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
Retrieve the DB flags for a database handle.
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_txn_renew(MDB_txn *txn)
Renew a read-only transaction.
unsigned __int64 uint64_t
int mdb_reader_check(MDB_env *env, int *dead)
Check for stale entries in the reader lock table.
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_cursor_renew(MDB_txn *txn, MDB_cursor *cursor)
Renew a cursor handle.
int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Set a custom key comparison function for a database.
mdb_size_t ms_overflow_pages
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
int mdb_env_sync(MDB_env *env, int force)
Flush the data buffers to disk.
mdb_size_t mdb_txn_id(MDB_txn *txn)
Return the transaction's ID.
int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd)
Return the filedescriptor for the given 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.
MDB_cursor_op
Cursor Get operations.
int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Retrieve by cursor.
int mdb_env_create(MDB_env **env)
Create an LMDB environment handle.
void mdb_txn_abort(MDB_txn *txn)
Abandon all the operations of the transaction instead of saving them.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
struct MDB_cursor MDB_cursor
Opaque structure for navigating through a database.
Generic structure used for passing keys and data in and out of the database.
int mdb_env_stat(MDB_env *env, MDB_stat *stat)
Return statistics about the LMDB environment.
char * mdb_strerror(int err)
Return a string describing a given error code.
int mdb_env_set_maxreaders(MDB_env *env, unsigned int readers)
Set the maximum number of threads/reader slots for the environment.
int() MDB_msg_func(const char *msg, void *ctx)
A callback function used to print a message from the library.
int mdb_env_set_flags(MDB_env *env, unsigned int flags, int onoff)
Set environment flags.
int mdb_env_set_userctx(MDB_env *env, void *ctx)
Set application information associated with the MDB_env.
int mdb_cursor_del(MDB_cursor *cursor, unsigned int flags)
Delete current key/data pair.
int mdb_env_copy2(MDB_env *env, const char *path, unsigned int flags)
Copy an LMDB environment to the specified path, with options.
struct MDB_stat MDB_stat
Statistics for a database in the environment.
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.
void mdb_env_close(MDB_env *env)
Close the environment and release the memory map.
int mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor)
Create a cursor handle.