diff --git a/mdbx.h b/mdbx.h index ec38193c..8d5a6e2e 100644 --- a/mdbx.h +++ b/mdbx.h @@ -79,6 +79,7 @@ typedef DWORD mdbx_tid_t; #define MDBX_EROFS ERROR_FILE_READ_ONLY #define MDBX_ENOSYS ERROR_NOT_SUPPORTED #define MDBX_EIO ERROR_WRITE_FAULT +#define MDBX_EPERM ERROR_INVALID_FUNCTION #else @@ -97,6 +98,7 @@ typedef pthread_t mdbx_tid_t; #define MDBX_EROFS EROFS #define MDBX_ENOSYS ENOSYS #define MDBX_EIO EIO +#define MDBX_EPERM EPERM #endif #ifdef _MSC_VER diff --git a/src/mdbx.c b/src/mdbx.c index 13768b29..417595ad 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -2434,6 +2434,9 @@ int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, unsigned flags, return MDBX_PANIC; } + if (unlikely(!env->me_map)) + return MDBX_EPERM; + flags &= MDBX_TXN_BEGIN_FLAGS; flags |= env->me_flags & MDBX_WRITEMAP;