From e989cb05ed038c0ed83e7247ed1828b7496339cb Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Tue, 7 Jul 2020 19:33:59 +0300 Subject: [PATCH] mdbx: deprecate mdbx_dbi_open_ex() and custom comparators. Change-Id: I1d20f77b9ba5d8d5ec891df17019377afb466b06 --- ChangeLog.md | 1 + mdbx.h | 6 +++--- src/core.c | 14 ++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 2208b212..eff36e1d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,5 @@ ## v0.9.x (in the development): +- Since v0.9 usage of custom comparators and the `mdbx_dbi_open_ex()` are deprecated. - TODO: API for explicit threads (de)registration. - TODO: Native bindings for C++. - TODO: Packages for AltLinux, Fedora/RHEL, Debian/Ubuntu. diff --git a/mdbx.h b/mdbx.h index ffc55824..e2dc6720 100644 --- a/mdbx.h +++ b/mdbx.h @@ -2678,9 +2678,9 @@ typedef int(MDBX_cmp_func)(const MDBX_val *a, const MDBX_val *b); * i.e. the passed flags is different with which the * database was created, or the database was already * opened with a different comparison function(s). */ -LIBMDBX_API int mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, - unsigned flags, MDBX_dbi *dbi, - MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp); +MDBX_DEPRECATED LIBMDBX_API int +mdbx_dbi_open_ex(MDBX_txn *txn, const char *name, unsigned flags, MDBX_dbi *dbi, + MDBX_cmp_func *keycmp, MDBX_cmp_func *datacmp); LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, unsigned flags, MDBX_dbi *dbi); diff --git a/src/core.c b/src/core.c index 14608262..a48ac0a8 100644 --- a/src/core.c +++ b/src/core.c @@ -16452,9 +16452,9 @@ static int mdbx_dbi_bind(MDBX_txn *txn, const MDBX_dbi dbi, unsigned user_flags, return MDBX_SUCCESS; } -int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags, - MDBX_dbi *dbi, MDBX_cmp_func *keycmp, - MDBX_cmp_func *datacmp) { +static int dbi_open(MDBX_txn *txn, const char *table_name, unsigned user_flags, + MDBX_dbi *dbi, MDBX_cmp_func *keycmp, + MDBX_cmp_func *datacmp) { int rc = MDBX_EINVAL; if (unlikely(!dbi)) return rc; @@ -16673,7 +16673,13 @@ int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags, int mdbx_dbi_open(MDBX_txn *txn, const char *table_name, unsigned table_flags, MDBX_dbi *dbi) { - return mdbx_dbi_open_ex(txn, table_name, table_flags, dbi, nullptr, nullptr); + return dbi_open(txn, table_name, table_flags, dbi, nullptr, nullptr); +} + +int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, + unsigned table_flags, MDBX_dbi *dbi, MDBX_cmp_func *keycmp, + MDBX_cmp_func *datacmp) { + return dbi_open(txn, table_name, table_flags, dbi, keycmp, datacmp); } int __cold mdbx_dbi_stat(MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *dest,