]> git.sur5r.net Git - openldap/blobdiff - libraries/liblmdb/lmdb.h
ITS#7672 fix mdb_dbi_flags
[openldap] / libraries / liblmdb / lmdb.h
index 9019b31bdcd2ca85a8c4c753e5fc8106771a6b6c..b2c3861ac99bf4f1632e3c27c5e1ab52a2f89500 100644 (file)
  *       cause further writes to grow the database quickly, and
  *       stale locks can block further operation.
  *
- *       Fix: Terminate all programs using the database, or make
- *       them close it.  Next database user will reset the lockfile.
+ *       Fix: Check for stale readers periodically, using the
+ *       #mdb_reader_check function or the mdb_stat tool. Or 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,
  *       startup can fail due to semaphores owned by another userid.
  *     ...when several processes can use a database concurrently:
  *
  *     - Avoid aborting a process with an active transaction.
- *       The transaction becomes "long-lived" as above until the lockfile
- *       is reset, since the process may not remove it from the lockfile.
+ *       The transaction becomes "long-lived" as above until a check
+ *       for stale readers is performed or the lockfile is reset,
+ *       since the process may not remove it from the lockfile.
  *
- *     - If you do that anyway, close the environment once in a while,
- *       so the lockfile can get reset.
+ *     - 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.
  *
  *     - Do not use MDB databases on remote filesystems, even between
  *       processes on the same host.  This breaks flock() on some OSes,
@@ -383,7 +386,7 @@ typedef enum MDB_cursor_op {
 #define MDB_PAGE_FULL  (-30786)
        /** Database contents grew beyond environment mapsize */
 #define MDB_MAP_RESIZED        (-30785)
-       /** Database flags changed or would change */
+       /** MDB_INCOMPATIBLE: Operation and DB incompatible, or DB flags changed */
 #define MDB_INCOMPATIBLE       (-30784)
        /** Invalid reuse of reader locktable slot */
 #define MDB_BAD_RSLOT          (-30783)
@@ -720,6 +723,13 @@ int  mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers);
         */
 int  mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs);
 
+       /** @brief Get the maximum size of a key for the environment.
+        *
+        * @param[in] env An environment handle returned by #mdb_env_create()
+        * @return The maximum size of a key. (#MDB_MAXKEYSIZE)
+        */
+int  mdb_env_get_maxkeysize(MDB_env *env);
+
        /** @brief Create a transaction for use with the environment.
         *
         * The transaction handle may be discarded using #mdb_txn_abort() or #mdb_txn_commit().
@@ -755,6 +765,12 @@ int  mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs);
         */
 int  mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn);
 
+       /** @brief Returns the transaction's #MDB_env
+        *
+        * @param[in] txn A transaction handle returned by #mdb_txn_begin()
+        */
+MDB_env *mdb_txn_env(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
@@ -904,12 +920,12 @@ int  mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat);
 
        /** @brief Retrieve the DB flags for a database handle.
         *
-        * @param[in] env An environment handle returned by #mdb_env_create()
+        * @param[in] txn A transaction handle returned by #mdb_txn_begin()
         * @param[in] dbi A database handle returned by #mdb_dbi_open()
         * @param[out] flags Address where the flags will be returned.
         * @return A non-zero error value on failure and 0 on success.
         */
-int mdb_dbi_flags(MDB_env *env, MDB_dbi dbi, unsigned int *flags);
+int mdb_dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags);
 
        /** @brief Close a database handle.
         *