mdbx: refine dbi_open_ex().

Change-Id: I32bc1c6609e14ba90b2f4eaf9b8b11ea06f2eb8b
This commit is contained in:
Leonid Yuriev 2020-01-19 14:45:16 +03:00
parent 7d880a37dd
commit 2c1d3a3fda

View File

@ -15403,13 +15403,14 @@ static int mdbx_dbi_bind(MDBX_txn *txn, const MDBX_dbi dbi, unsigned user_flags,
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) {
if (unlikely(!dbi || (user_flags & ~VALID_FLAGS) != 0))
return MDBX_EINVAL;
*dbi = (MDBX_dbi)-1;
int rc = check_txn(txn, MDBX_TXN_BLOCKED);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
if (unlikely(!dbi || (user_flags & ~VALID_FLAGS) != 0))
return MDBX_EINVAL;
switch (user_flags &
(MDBX_INTEGERDUP | MDBX_DUPFIXED | MDBX_DUPSORT | MDBX_REVERSEDUP)) {
default:
@ -15426,8 +15427,10 @@ int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags,
/* main table? */
if (!table_name) {
*dbi = MAIN_DBI;
return mdbx_dbi_bind(txn, MAIN_DBI, user_flags, keycmp, datacmp);
rc = mdbx_dbi_bind(txn, MAIN_DBI, user_flags, keycmp, datacmp);
if (likely(rc == MDBX_SUCCESS))
*dbi = MAIN_DBI;
return rc;
}
if (txn->mt_dbxs[MAIN_DBI].md_cmp == NULL) {