From 45f8197635e4f949c58155173b8c2cb138fb48e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 24 Mar 2022 00:19:34 +0300 Subject: [PATCH] mdbx: clarify/refine error messages of a signature/version mismatch. --- src/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core.c b/src/core.c index 82fd1405..4ed205ec 100644 --- a/src/core.c +++ b/src/core.c @@ -12524,14 +12524,19 @@ __cold static int mdbx_setup_lck(MDBX_env *env, char *lck_pathname, } } else { if (lck->mti_magic_and_version != MDBX_LOCK_MAGIC) { - mdbx_error("%s", "lock region has invalid magic/version"); - err = ((lck->mti_magic_and_version >> 8) != MDBX_MAGIC) - ? MDBX_INVALID - : MDBX_VERSION_MISMATCH; + const bool invalid = (lck->mti_magic_and_version >> 8) != MDBX_MAGIC; + mdbx_error( + "lock region has %s", + invalid + ? "invalid magic" + : "incompatible version (only applications with nearly or the " + "same versions of libmdbx can share the same database)"); + err = invalid ? MDBX_INVALID : MDBX_VERSION_MISMATCH; goto bailout; } if (lck->mti_os_and_format != MDBX_LOCK_FORMAT) { - mdbx_error("lock region has os/format 0x%" PRIx32 ", expected 0x%" PRIx32, + mdbx_error("lock region has os/format signature 0x%" PRIx32 + ", expected 0x%" PRIx32, lck->mti_os_and_format, MDBX_LOCK_FORMAT); err = MDBX_VERSION_MISMATCH; goto bailout;