From 82d3595b760b9cc3c213411e3e941bc05cc3f364 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Mon, 22 May 2017 14:02:33 +0300 Subject: [PATCH] mdbx: add MDBX_EKEYMISMATCH. --- mdbx.h | 4 ++++ src/mdbx.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mdbx.h b/mdbx.h index 6a51768d..aa9c2653 100644 --- a/mdbx.h +++ b/mdbx.h @@ -328,6 +328,10 @@ typedef enum MDB_cursor_op { * right now (e.g. in readonly mode and so forth). */ #define MDBX_WANNA_RECOVERY (-30419) +/* The given key value is mismatched to the current cursor position, + * when mdbx_cursor_put() called with MDB_CURRENT option. */ +#define MDBX_EKEYMISMATCH (-30418) + /* Statistics for a database in the environment */ typedef struct MDBX_stat { unsigned ms_psize; /* Size of a database page. diff --git a/src/mdbx.c b/src/mdbx.c index 699d0bff..997bf987 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -759,6 +759,9 @@ static const char *__mdbx_strerr(int errnum) { case MDBX_WANNA_RECOVERY: return "MDBX_WANNA_RECOVERY: Database should be recovered, but this could " "be done in a read-only mode"; + case MDBX_EKEYMISMATCH: + return "MDBX_EKEYMISMATCH: The given key value is mismatched to the " + "current cursor position"; default: return NULL; } @@ -5729,7 +5732,7 @@ int mdbx_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, mc->mc_ki[mc->mc_top]++; } else { /* new key is <= last key */ - rc = MDB_KEYEXIST; + rc = MDBX_EKEYMISMATCH; } } } else {