lmdb_master_sys

Function mdb_dbi_open

Source
pub unsafe extern "C" fn mdb_dbi_open(
    txn: *mut MDB_txn,
    name: *const c_char,
    flags: c_uint,
    dbi: *mut MDB_dbi,
) -> c_int
Expand description

Open a database in the environment.

A database handle denotes the name and parameters of a database, independently of whether such a database exists. The database handle may be discarded by calling #mdb_dbi_close(). The old database handle is returned if the database was already open. The handle may only be closed once.

The database handle will be private to the current transaction until the transaction is successfully committed. If the transaction is aborted the handle will be closed automatically. After a successful commit the handle will reside in the shared environment, and may be used by other transactions.

This function must not be called from multiple concurrent transactions in the same process. A transaction that uses this function must finish (either commit or abort) before 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 keys in the unnamed database, and may be read but not written.

§Arguments

  • txn (direction in) - A transaction handle returned by #mdb_txn_begin()
  • name (direction in) - The name of the database to open. If only a single database is needed in the environment, this value may be NULL.
  • flags (direction in) - Special options for this database. This parameter must be set to 0 or by bitwise OR’ing together one or more of the values described here.
  • #MDB_REVERSEKEY Keys are strings to be compared in reverse order, from the end of the strings to the beginning. By default, Keys are treated as strings and compared from beginning to end.
  • #MDB_DUPSORT Duplicate keys may be used in the database. (Or, from another perspective, keys may have multiple data items, stored in sorted order.) By default keys must be unique and may have only a single data item.
  • #MDB_INTEGERKEY Keys are binary integers in native byte order, either unsigned int or #mdb_size_t, and will be sorted as such. (lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.) The keys must all be of the same size.
  • #MDB_DUPFIXED This flag may only be used in combination with #MDB_DUPSORT. This option tells the library that the data items for this database are all the same size, which allows further optimizations in storage and retrieval. When all data items are the same size, the #MDB_GET_MULTIPLE, #MDB_NEXT_MULTIPLE and #MDB_PREV_MULTIPLE cursor operations may be used to retrieve multiple items at once.
  • #MDB_INTEGERDUP This option specifies that duplicate data items are binary integers, similar to #MDB_INTEGERKEY keys.
  • #MDB_REVERSEDUP This option specifies that duplicate data items should be compared as strings in reverse order.
  • #MDB_CREATE Create the named database if it doesn't exist. This option is not allowed in a read-only transaction or a read-only environment.
* `dbi` (direction out) - Address where the new #MDB_dbi handle will be stored # Returns

A non-zero error value on failure and 0 on success. Some possible errors are:

  • #MDB_NOTFOUND - the specified database doesn't exist in the environment and #MDB_CREATE was not specified.
  • #MDB_DBS_FULL - too many databases have been opened. See #mdb_env_set_maxdbs().