mdbx: fix MDBX_NODUPDATA handling for key-value data.

More for https://github.com/erthink/libmdbx/issues/99
in continue to 9428efd2ae9f7fe984422b5eb1fc47f732236b51

Change-Id: I56050ddf5e56807a11d8613780c3ba76cc16d324
This commit is contained in:
Leonid Yuriev 2020-05-13 00:10:58 +03:00
parent 8c8c86038a
commit e28d223d42

View File

@ -12023,10 +12023,12 @@ int mdbx_cursor_put(MDBX_cursor *mc, const MDBX_val *key, MDBX_val *data,
if (exact) {
if (mc->mc_flags & C_SUB) {
mdbx_assert(env, data->iov_len == 0 && olddata.iov_len == 0);
return rc;
return (flags & MDBX_NODUPDATA) ? MDBX_KEYEXIST : MDBX_SUCCESS;
}
if (!(flags & MDBX_RESERVE) && mc->mc_dbx->md_dcmp(data, &olddata) == 0)
return rc;
if (!(flags & MDBX_RESERVE) &&
unlikely(mc->mc_dbx->md_dcmp(data, &olddata) == 0))
return ((flags & MDBX_NODUPDATA) && mc->mc_xcursor) ? MDBX_KEYEXIST
: MDBX_SUCCESS;
}
} else if (unlikely(rc != MDBX_NOTFOUND))
return rc;