mdbx: add mdbx_env_get_maxdbs().

Change-Id: Ie4bdd2f8a46130f277ef98861a5fca98f55bad54
This commit is contained in:
Leonid Yuriev 2020-07-27 16:26:19 +03:00
parent 9e90718bd5
commit b91918b027
2 changed files with 25 additions and 0 deletions

13
mdbx.h
View File

@ -2197,6 +2197,7 @@ LIBMDBX_API int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers);
* Currently a moderate number of slots are cheap but a huge number gets
* expensive: 7-120 words per transaction, and every \ref mdbx_dbi_open()
* does a linear search of the opened slots.
* \see mdbx_env_get_maxdbs()
*
* \param [in] env An environment handle returned by \ref mdbx_env_create().
* \param [in] dbs The maximum number of databases.
@ -2207,6 +2208,18 @@ LIBMDBX_API int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers);
* \retval MDBX_EPERM The environment is already open. */
LIBMDBX_API int mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs);
/** Get the maximum number of named databases for the environment.
* \ingroup c_statinfo
* \see mdbx_env_set_maxdbs()
*
* \param [in] env An environment handle returned by \ref mdbx_env_create().
* \param [out] dbs Address to store the maximum number of databases.
*
* \returns A non-zero error value on failure and 0 on success,
* some possible errors are:
* \retval MDBX_EINVAL An invalid parameter was specified. */
LIBMDBX_API int mdbx_env_get_maxdbs(MDBX_env *env, MDBX_dbi *dbs);
/** Get the maximum size of keys can write.
* \ingroup c_statinfo
*

View File

@ -9259,6 +9259,18 @@ int __cold mdbx_env_set_maxdbs(MDBX_env *env, MDBX_dbi dbs) {
return MDBX_SUCCESS;
}
int __cold mdbx_env_get_maxdbs(MDBX_env *env, MDBX_dbi *dbs) {
int rc = check_env(env);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
if (unlikely(!dbs))
return MDBX_EINVAL;
*dbs = env->me_maxdbs;
return MDBX_SUCCESS;
}
int __cold mdbx_env_set_maxreaders(MDBX_env *env, unsigned readers) {
int rc = check_env(env);
if (unlikely(rc != MDBX_SUCCESS))