diff --git a/mdbx.c b/mdbx.c index a6b9468f..6b988e58 100644 --- a/mdbx.c +++ b/mdbx.c @@ -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; } diff --git a/mdbx.h b/mdbx.h index 83315e54..73d325ed 100644 --- a/mdbx.h +++ b/mdbx.h @@ -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); /** @} */