mdb_dcmp(): Assume the database has MDB_DUPSORT.

There was little point in returning EINVAL when not: Comparing (A,B)
and (B,A) would claim (A > B && B > A), which could confuse callers.
vmware
Hallvard Furuseth 12 years ago
parent 91a93004ce
commit b389341b4b
  1. 2
      libraries/liblmdb/lmdb.h
  2. 5
      libraries/liblmdb/mdb.c

@ -1252,7 +1252,7 @@ int mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);
/** @brief Compare two data items according to a particular database.
*
* This returns a comparison as if the two items were data items of
* a sorted duplicates #MDB_DUPSORT database.
* the specified database. The database must have the #MDB_DUPSORT flag.
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
* @param[in] dbi A database handle returned by #mdb_dbi_open()
* @param[in] a The first item to compare

@ -1246,10 +1246,7 @@ mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b)
int
mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b)
{
if (txn->mt_dbxs[dbi].md_dcmp)
return txn->mt_dbxs[dbi].md_dcmp(a, b);
else
return EINVAL; /* too bad you can't distinguish this from a valid result */
return txn->mt_dbxs[dbi].md_dcmp(a, b);
}
/** Allocate a single page.

Loading…
Cancel
Save