Function lmdb_master_sys::mdb_set_compare

source ·
pub unsafe extern "C" fn mdb_set_compare(
    txn: *mut MDB_txn,
    dbi: MDB_dbi,
    cmp: MDB_cmp_func,
) -> c_int
Expand description

Set a custom key comparison function for a database.

The comparison function is called whenever it is necessary to compare a key specified by the application with a key currently stored in the database. If no comparison function is specified, and no special key flags were specified with #mdb_dbi_open(), the keys are compared lexically, with shorter keys collating before longer keys. This function must be called before any data access functions are used, otherwise data corruption may occur. The same comparison function must be used by every program accessing the database, every time the database is used.

§Arguments

  • txn (direction in) - A transaction handle returned by #mdb_txn_begin()
  • dbi (direction in) - A database handle returned by #mdb_dbi_open()
  • cmp (direction in) - A #MDB_cmp_func function

§Returns

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

  • EINVAL - an invalid parameter was specified.