From b389341b4b2413804726276d01676a6a9d05346f Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 4 May 2013 12:34:49 +0200 Subject: [PATCH] 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. --- libraries/liblmdb/lmdb.h | 2 +- libraries/liblmdb/mdb.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 10eb897..954ffde 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 0df2142..b6e85a5 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.