mdb_get function

int mdb_get(
  1. Pointer<MDB_txn> txn,
  2. int dbi,
  3. Pointer<MDB_val> key,
  4. Pointer<MDB_val> data,
)

@brief Get items from a database.

This function retrieves key/data pairs from the database. The address and length of the data associated with the specified \b key are returned in the structure to which \b data refers. If the database supports duplicate keys (#MDB_DUPSORT) then the first data item for the key will be returned. Retrieval of other items requires the use of #mdb_cursor_get().

@note The memory pointed to by the returned values is owned by the database. The caller need not dispose of the memory, and may not modify it in any way. For values returned in a read-only transaction any modification attempts will cause a SIGSEGV. @note Values returned from the database are valid only until a subsequent update operation, or the end of the transaction. @paramin txn A transaction handle returned by #mdb_txn_begin() @paramin dbi A database handle returned by #mdb_dbi_open() @paramin key The key to search for in the database @paramout data The data corresponding to the key @return A non-zero error value on failure and 0 on success. Some possible errors are:

  • #MDB_NOTFOUND - the key was not in the database.
  • EINVAL - an invalid parameter was specified.

Implementation

@ffi.FfiNative<
    ffi.Int Function(ffi.Pointer<MDB_txn>, MDB_dbi, ffi.Pointer<MDB_val>,
        ffi.Pointer<MDB_val>)>('mdb_get')
external int mdb_get(
  ffi.Pointer<MDB_txn> txn,
  int dbi,
  ffi.Pointer<MDB_val> key,
  ffi.Pointer<MDB_val> data,
);