mdbx: mdbx_cursor_put(MDBX_APPEND+MDBX_NOOVERWRITE) should return MDBX_KEYEXIST instead of MDBX_EKEYMISMATCH.

When MDBX_APPEND is used the ordering of keys is important.
Therefore MDBX_EKEYMISMATCH should me returned when given key <= last.

On the other hand, if MDBX_NOOVERWRITE is also used
then the MDBX_KEYEXIST should be returned, but not MDBX_EKEYMISMATCH.
This commit is contained in:
Leo Yuriev 2018-03-23 17:11:18 +03:00
parent 6758348046
commit 45f159ddd3

View File

@ -7195,7 +7195,8 @@ int mdbx_cursor_put(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
} else { } else {
rc = mdbx_cursor_set(mc, key, &d2, MDBX_SET, &exact); rc = mdbx_cursor_set(mc, key, &d2, MDBX_SET, &exact);
} }
if ((flags & MDBX_NOOVERWRITE) && rc == 0) { if ((flags & MDBX_NOOVERWRITE) &&
(rc == MDBX_SUCCESS || rc == MDBX_EKEYMISMATCH)) {
mdbx_debug("duplicate key [%s]", DKEY(key)); mdbx_debug("duplicate key [%s]", DKEY(key));
*data = d2; *data = d2;
return MDBX_KEYEXIST; return MDBX_KEYEXIST;