diff --git a/src/core.c b/src/core.c index 3537dd0d..b6176d6d 100644 --- a/src/core.c +++ b/src/core.c @@ -16284,8 +16284,9 @@ static int mdbx_dbi_bind(MDBX_txn *txn, const MDBX_dbi dbi, unsigned user_flags, */ if ((user_flags ^ txn->mt_dbs[dbi].md_flags) & PERSISTENT_FLAGS) { /* flags ara differs, check other conditions */ - if (!user_flags && (!keycmp || keycmp == txn->mt_dbxs[dbi].md_cmp) && - (!datacmp || datacmp == txn->mt_dbxs[dbi].md_dcmp)) { + if ((!user_flags && (!keycmp || keycmp == txn->mt_dbxs[dbi].md_cmp) && + (!datacmp || datacmp == txn->mt_dbxs[dbi].md_dcmp)) || + user_flags == MDBX_ACCEDE) { /* no comparators were provided and flags are zero, * seems that is case #1 above */ user_flags = txn->mt_dbs[dbi].md_flags; @@ -16338,8 +16339,12 @@ int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags, if (unlikely(rc != MDBX_SUCCESS)) goto early_bailout; - switch (user_flags & - (MDBX_INTEGERDUP | MDBX_DUPFIXED | MDBX_DUPSORT | MDBX_REVERSEDUP)) { + switch (user_flags & (MDBX_INTEGERDUP | MDBX_DUPFIXED | MDBX_DUPSORT | + MDBX_REVERSEDUP | MDBX_ACCEDE)) { + case MDBX_ACCEDE: + if ((user_flags & MDBX_CREATE) == 0) + break; + __fallthrough /* fall through */; default: rc = MDBX_EINVAL; goto early_bailout; diff --git a/src/internals.h b/src/internals.h index 27b11e52..650ea3c4 100644 --- a/src/internals.h +++ b/src/internals.h @@ -1285,7 +1285,7 @@ typedef struct MDBX_node { /* mdbx_dbi_open() flags */ #define VALID_FLAGS \ (MDBX_REVERSEKEY | MDBX_DUPSORT | MDBX_INTEGERKEY | MDBX_DUPFIXED | \ - MDBX_INTEGERDUP | MDBX_REVERSEDUP | MDBX_CREATE) + MDBX_INTEGERDUP | MDBX_REVERSEDUP | MDBX_CREATE | MDBX_ACCEDE) /* max number of pages to commit in one writev() call */ #define MDBX_COMMIT_PAGES 64 diff --git a/src/mdbx_chk.c b/src/mdbx_chk.c index b3fa0252..657a28a7 100644 --- a/src/mdbx_chk.c +++ b/src/mdbx_chk.c @@ -574,7 +574,7 @@ static int process_db(MDBX_dbi dbi_handle, char *dbi_name, visitor *handler, if (dbi_handle == ~0u) { rc = mdbx_dbi_open_ex( - txn, dbi_name, 0, &dbi_handle, + txn, dbi_name, MDBX_ACCEDE, &dbi_handle, (dbi_name && ignore_wrong_order) ? equal_or_greater : nullptr, (dbi_name && ignore_wrong_order) ? equal_or_greater : nullptr); if (rc) { diff --git a/src/mdbx_dump.c b/src/mdbx_dump.c index f97c030a..b921a813 100644 --- a/src/mdbx_dump.c +++ b/src/mdbx_dump.c @@ -356,7 +356,7 @@ int main(int argc, char *argv[]) { goto env_close; } - rc = mdbx_dbi_open(txn, subname, 0, &dbi); + rc = mdbx_dbi_open(txn, subname, MDBX_ACCEDE, &dbi); if (unlikely(rc != MDBX_SUCCESS)) { error("mdbx_dbi_open", rc); goto txn_abort; @@ -394,7 +394,7 @@ int main(int argc, char *argv[]) { subname[key.iov_len] = '\0'; MDBX_dbi sub_dbi; - rc = mdbx_dbi_open_ex(txn, subname, 0, &sub_dbi, + rc = mdbx_dbi_open_ex(txn, subname, MDBX_ACCEDE, &sub_dbi, rescue ? equal_or_greater : nullptr, rescue ? equal_or_greater : nullptr); if (unlikely(rc != MDBX_SUCCESS)) { diff --git a/src/mdbx_stat.c b/src/mdbx_stat.c index d7d2b479..df12717a 100644 --- a/src/mdbx_stat.c +++ b/src/mdbx_stat.c @@ -396,7 +396,7 @@ int main(int argc, char *argv[]) { printf(" GC: %" PRIaPGNO " pages\n", pages); } - rc = mdbx_dbi_open(txn, subname, 0, &dbi); + rc = mdbx_dbi_open(txn, subname, MDBX_ACCEDE, &dbi); if (unlikely(rc != MDBX_SUCCESS)) { error("mdbx_dbi_open", rc); goto txn_abort; @@ -426,7 +426,7 @@ int main(int argc, char *argv[]) { subname = mdbx_malloc(key.iov_len + 1); memcpy(subname, key.iov_base, key.iov_len); subname[key.iov_len] = '\0'; - rc = mdbx_dbi_open(txn, subname, 0, &subdbi); + rc = mdbx_dbi_open(txn, subname, MDBX_ACCEDE, &subdbi); if (rc == MDBX_SUCCESS) printf("Status of %s\n", subname); mdbx_free(subname);