mdbx: add MDBX_EKEYMISMATCH.

This commit is contained in:
Leo Yuriev 2017-05-22 14:02:33 +03:00
parent d9eeac45b2
commit 82d3595b76
2 changed files with 8 additions and 1 deletions

4
mdbx.h
View File

@ -328,6 +328,10 @@ typedef enum MDB_cursor_op {
* right now (e.g. in readonly mode and so forth). */ * right now (e.g. in readonly mode and so forth). */
#define MDBX_WANNA_RECOVERY (-30419) #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 */ /* Statistics for a database in the environment */
typedef struct MDBX_stat { typedef struct MDBX_stat {
unsigned ms_psize; /* Size of a database page. unsigned ms_psize; /* Size of a database page.

View File

@ -759,6 +759,9 @@ static const char *__mdbx_strerr(int errnum) {
case MDBX_WANNA_RECOVERY: case MDBX_WANNA_RECOVERY:
return "MDBX_WANNA_RECOVERY: Database should be recovered, but this could " return "MDBX_WANNA_RECOVERY: Database should be recovered, but this could "
"be done in a read-only mode"; "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: default:
return NULL; 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]++; mc->mc_ki[mc->mc_top]++;
} else { } else {
/* new key is <= last key */ /* new key is <= last key */
rc = MDB_KEYEXIST; rc = MDBX_EKEYMISMATCH;
} }
} }
} else { } else {