mdbx: use MDB_SET_KEY inside mdbx_replace() for libfpta.

This commit is contained in:
Leo Yuriev 2017-01-27 03:18:51 +03:00
parent a148bcea70
commit 72de33c8e9
2 changed files with 9 additions and 7 deletions

10
mdbx.c
View File

@ -448,7 +448,7 @@ int mdbx_replace(MDB_txn *txn, MDB_dbi dbi,
if (new_data && mdbx_is_samedata(old_data, new_data))
goto bailout;
} else {
/* в old_data буфер получения предыдущего значения */
/* в old_data буфер для сохранения предыдущего значения */
if (unlikely(new_data && old_data->iov_base == new_data->iov_base))
return EINVAL;
MDB_val present_data;
@ -541,7 +541,7 @@ mdbx_get_ex(MDB_txn *txn, MDB_dbi dbi,
mdb_cursor_init(&mc, txn, dbi, &mx);
int exact = 0;
int rc = mdb_cursor_set(&mc, key, data, MDB_SET, &exact);
int rc = mdb_cursor_set(&mc, key, data, MDB_SET_KEY, &exact);
if (unlikely(rc != MDB_SUCCESS)) {
if (rc == MDB_NOTFOUND && values_count)
*values_count = 0;
@ -561,11 +561,11 @@ mdbx_get_ex(MDB_txn *txn, MDB_dbi dbi,
*values_count = 1;
else {
mdb_tassert(txn, mc.mc_xcursor == &mx);
mdb_tassert(txn, mx.mx_cursor.mc_flags & C_INITIALIZED);
mdb_tassert(txn, mx.mx_cursor.mc_flags & C_INITIALIZED);
*values_count = mx.mx_db.md_entries;
}
}
}
}
return MDB_SUCCESS;
}
return MDB_SUCCESS;
}

6
mdbx.h
View File

@ -227,8 +227,10 @@ int mdbx_cursor_eof(MDB_cursor *mc);
int mdbx_replace(MDB_txn *txn, MDB_dbi dbi,
MDB_val *key, MDB_val *new_data, MDB_val *old_data, unsigned flags);
/* Same as mdbx_get(), but also return the count
* of multi-values/duplicates for a given key. */
/* Same as mdbx_get(), but:
* 1) if values_count is not NULL, then returns the count
* of multi-values/duplicates for a given key.
* 2) updates the key for pointing to the actual key's data inside DB. */
int mdbx_get_ex(MDB_txn *txn, MDB_dbi dbi, MDB_val *key, MDB_val *data, int* values_count);
/** @} */