aboutsummaryrefslogtreecommitdiff
path: root/external/db_drivers/liblmdb/lmdb.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--external/db_drivers/liblmdb/lmdb.h (renamed from external/db_drivers/liblmdb32/lmdb.h)91
1 files changed, 68 insertions, 23 deletions
diff --git a/external/db_drivers/liblmdb32/lmdb.h b/external/db_drivers/liblmdb/lmdb.h
index 2f523579c..587a44eaf 100644
--- a/external/db_drivers/liblmdb32/lmdb.h
+++ b/external/db_drivers/liblmdb/lmdb.h
@@ -40,6 +40,9 @@
* corrupt the database. Of course if your application code is known to
* be bug-free (...) then this is not an issue.
*
+ * If this is your first time using a transactional embedded key/value
+ * store, you may find the \ref starting page to be helpful.
+ *
* @section caveats_sec Caveats
* Troubleshooting the lock file, plus semaphores on BSD systems:
*
@@ -49,11 +52,16 @@
* stale locks can block further operation.
*
* Fix: Check for stale readers periodically, using the
- * #mdb_reader_check function or the \ref mdb_stat_1 "mdb_stat" tool. Or just
- * make all programs using the database close it; the lockfile
- * is always reset on first open of the environment.
+ * #mdb_reader_check function or the \ref mdb_stat_1 "mdb_stat" tool.
+ * Stale writers will be cleared automatically on most systems:
+ * - Windows - automatic
+ * - BSD, systems using SysV semaphores - automatic
+ * - Linux, systems using POSIX mutexes with Robust option - automatic
+ * Otherwise just make all programs using the database close it;
+ * the lockfile is always reset on first open of the environment.
*
- * - On BSD systems or others configured with MDB_USE_POSIX_SEM,
+ * - On BSD systems or others configured with MDB_USE_SYSV_SEM or
+ * MDB_USE_POSIX_SEM,
* startup can fail due to semaphores owned by another userid.
*
* Fix: Open and close the database as the user which owns the
@@ -106,6 +114,9 @@
* for stale readers is performed or the lockfile is reset,
* since the process may not remove it from the lockfile.
*
+ * This does not apply to write transactions if the system clears
+ * stale writers, see above.
+ *
* - If you do that anyway, do a periodic check for stale readers. Or
* close the environment once in a while, so the lockfile can get reset.
*
@@ -150,6 +161,7 @@
#define _LMDB_H_
#include <sys/types.h>
+#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
@@ -162,6 +174,13 @@ typedef int mdb_mode_t;
typedef mode_t mdb_mode_t;
#endif
+#ifdef MDB_VL32
+typedef uint64_t mdb_size_t;
+#define mdb_env_create(env) mdb_env_create_vl32(env) /**< Prevent mixing with non-VL32 builds */
+#else
+typedef size_t mdb_size_t;
+#endif
+
/** An abstraction for a file handle.
* On POSIX systems file handles are small integers. On Windows
* they're opaque pointers.
@@ -184,7 +203,7 @@ typedef int mdb_filehandle_t;
/** Library minor version */
#define MDB_VERSION_MINOR 9
/** Library patch version */
-#define MDB_VERSION_PATCH 15
+#define MDB_VERSION_PATCH 70
/** Combine args a,b,c into a single integer for easy version comparisons */
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
@@ -194,7 +213,7 @@ typedef int mdb_filehandle_t;
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
/** The release date of this library version */
-#define MDB_VERSION_DATE "June 19, 2015"
+#define MDB_VERSION_DATE "December 19, 2015"
/** A stringifier for the version info */
#define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")"
@@ -391,7 +410,7 @@ typedef enum MDB_cursor_op {
#define MDB_PAGE_NOTFOUND (-30797)
/** Located page was wrong type */
#define MDB_CORRUPTED (-30796)
- /** Update of meta page failed, probably I/O error */
+ /** Update of meta page failed or environment had fatal error */
#define MDB_PANIC (-30795)
/** Environment version mismatch */
#define MDB_VERSION_MISMATCH (-30794)
@@ -413,11 +432,18 @@ typedef enum MDB_cursor_op {
#define MDB_PAGE_FULL (-30786)
/** Database contents grew beyond environment mapsize */
#define MDB_MAP_RESIZED (-30785)
- /** MDB_INCOMPATIBLE: Operation and DB incompatible, or DB flags changed */
+ /** Operation and DB incompatible, or DB type changed. This can mean:
+ * <ul>
+ * <li>The operation expects an #MDB_DUPSORT / #MDB_DUPFIXED database.
+ * <li>Opening a named DB when the unnamed DB has #MDB_DUPSORT / #MDB_INTEGERKEY.
+ * <li>Accessing a data record as a database, or vice versa.
+ * <li>The database was dropped and recreated with different flags.
+ * </ul>
+ */
#define MDB_INCOMPATIBLE (-30784)
/** Invalid reuse of reader locktable slot */
#define MDB_BAD_RSLOT (-30783)
- /** Transaction cannot recover - it must be aborted */
+ /** Transaction must abort, has a child, or is invalid */
#define MDB_BAD_TXN (-30782)
/** Unsupported size of key/DB name/data, or wrong DUPFIXED size */
#define MDB_BAD_VALSIZE (-30781)
@@ -432,18 +458,18 @@ typedef struct MDB_stat {
unsigned int ms_psize; /**< Size of a database page.
This is currently the same for all databases. */
unsigned int ms_depth; /**< Depth (height) of the B-tree */
- size_t ms_branch_pages; /**< Number of internal (non-leaf) pages */
- size_t ms_leaf_pages; /**< Number of leaf pages */
- size_t ms_overflow_pages; /**< Number of overflow pages */
- size_t ms_entries; /**< Number of data items */
+ mdb_size_t ms_branch_pages; /**< Number of internal (non-leaf) pages */
+ mdb_size_t ms_leaf_pages; /**< Number of leaf pages */
+ mdb_size_t ms_overflow_pages; /**< Number of overflow pages */
+ mdb_size_t ms_entries; /**< Number of data items */
} MDB_stat;
/** @brief Information about the environment */
typedef struct MDB_envinfo {
void *me_mapaddr; /**< Address of map, if fixed */
- size_t me_mapsize; /**< Size of the data memory map */
- size_t me_last_pgno; /**< ID of the last used page */
- size_t me_last_txnid; /**< ID of the last committed transaction */
+ mdb_size_t me_mapsize; /**< Size of the data memory map */
+ mdb_size_t me_last_pgno; /**< ID of the last used page */
+ mdb_size_t me_last_txnid; /**< ID of the last committed transaction */
unsigned int me_maxreaders; /**< max reader slots in the environment */
unsigned int me_numreaders; /**< max reader slots used in the environment */
} MDB_envinfo;
@@ -810,7 +836,7 @@ int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd);
* an active write transaction.
* </ul>
*/
-int mdb_env_set_mapsize(MDB_env *env, size_t size);
+int mdb_env_set_mapsize(MDB_env *env, mdb_size_t size);
/** @brief Set the maximum number of threads/reader slots for the environment.
*
@@ -923,6 +949,10 @@ int mdb_env_set_assert(MDB_env *env, MDB_assert_func *func);
* <ul>
* <li>#MDB_RDONLY
* This transaction will not perform any write operations.
+ * <li>#MDB_NOSYNC
+ * Don't flush system buffers to disk when committing this transaction.
+ * <li>#MDB_NOMETASYNC
+ * Flush system buffers but omit metadata flush when committing this transaction.
* </ul>
* @param[out] txn Address where the new #MDB_txn handle will be stored
* @return A non-zero error value on failure and 0 on success. Some possible
@@ -946,6 +976,17 @@ int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **
*/
MDB_env *mdb_txn_env(MDB_txn *txn);
+ /** @brief Return the transaction's ID.
+ *
+ * This returns the identifier associated with this transaction. For a
+ * read-only transaction, this corresponds to the snapshot being read;
+ * concurrent readers will frequently have the same transaction ID.
+ *
+ * @param[in] txn A transaction handle returned by #mdb_txn_begin()
+ * @return A transaction ID, valid if input is an active transaction.
+ */
+mdb_size_t mdb_txn_id(MDB_txn *txn);
+
/** @brief Commit all the operations of a transaction into the database.
*
* The transaction handle is freed. It and its cursors must not be used
@@ -1034,8 +1075,9 @@ int mdb_txn_renew(MDB_txn *txn);
* any other transaction in the process may use this function.
*
* To use named databases (with name != NULL), #mdb_env_set_maxdbs()
- * must be called before opening the environment. Database names
- * are kept as keys in the unnamed database.
+ * must be called before opening the environment. Database names are
+ * keys in the unnamed database, and may be read but not written.
+ *
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
* @param[in] name The name of the database to open. If only a single
* database is needed in the environment, this value may be NULL.
@@ -1272,7 +1314,8 @@ int mdb_get(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data);
* the next update operation or the transaction ends. This saves
* an extra memcpy if the data is being generated later.
* LMDB does nothing else with this memory, the caller is expected
- * to modify all of the space requested.
+ * to modify all of the space requested. This flag must not be
+ * specified if the database was opened with #MDB_DUPSORT.
* <li>#MDB_APPEND - append the given key/data pair to the end of the
* database. This option allows fast bulk loading when keys are
* already known to be in the correct order. Loading unsorted keys
@@ -1428,13 +1471,15 @@ int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
* the database supports duplicates (#MDB_DUPSORT).
* <li>#MDB_RESERVE - reserve space for data of the given size, but
* don't copy the given data. Instead, return a pointer to the
- * reserved space, which the caller can fill in later. This saves
- * an extra memcpy if the data is being generated later.
+ * reserved space, which the caller can fill in later - before
+ * the next update operation or the transaction ends. This saves
+ * an extra memcpy if the data is being generated later. This flag
+ * must not be specified if the database was opened with #MDB_DUPSORT.
* <li>#MDB_APPEND - append the given key/data pair to the end of the
* database. No key comparisons are performed. This option allows
* fast bulk loading when keys are already known to be in the
* correct order. Loading unsorted keys with this flag will cause
- * data corruption.
+ * a #MDB_KEYEXIST error.
* <li>#MDB_APPENDDUP - as above, but for sorted dup data.
* <li>#MDB_MULTIPLE - store multiple contiguous data elements in a
* single request. This flag may only be specified if the database