mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:04:13 +08:00
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:
parent
6758348046
commit
45f159ddd3
@ -7195,7 +7195,8 @@ int mdbx_cursor_put(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
||||
} else {
|
||||
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));
|
||||
*data = d2;
|
||||
return MDBX_KEYEXIST;
|
||||
|
Loading…
x
Reference in New Issue
Block a user