From: Hallvard Furuseth Date: Sat, 4 May 2013 10:34:49 +0000 (+0200) Subject: mdb_dcmp(): Assume the database has MDB_DUPSORT. X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~68^2~6 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b389341b4b2413804726276d01676a6a9d05346f;p=openldap 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. --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 10eb8973ba..954ffde1cb 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -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 diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 0df2142dc2..b6e85a542c 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -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.