1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

lib ldb key value: convert TDB_DATA structs to ldb_val

Convert the key value functions to use ldb_val instead of TDB_DATA.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Jul 30 17:23:22 CEST 2018 on sn-devel-144
This commit is contained in:
Gary Lockyer 2018-07-23 13:20:46 +12:00 committed by Andrew Bartlett
parent f2d5c2c5cc
commit c891df4218
4 changed files with 109 additions and 137 deletions

View File

@ -63,25 +63,25 @@ struct ldb_kv_req_spy {
* Determine if this key could hold a record. We allow the new GUID
* index, the old DN index and a possible future ID=
*/
bool ldb_kv_key_is_record(TDB_DATA key)
bool ldb_kv_key_is_record(struct ldb_val key)
{
if (key.dsize < 4) {
if (key.length < 4) {
return false;
}
if (memcmp(key.dptr, "DN=", 3) == 0) {
if (memcmp(key.data, "DN=", 3) == 0) {
return true;
}
if (memcmp(key.dptr, "ID=", 3) == 0) {
if (memcmp(key.data, "ID=", 3) == 0) {
return true;
}
if (key.dsize < sizeof(LDB_KV_GUID_KEY_PREFIX)) {
if (key.length < sizeof(LDB_KV_GUID_KEY_PREFIX)) {
return false;
}
if (memcmp(key.dptr, LDB_KV_GUID_KEY_PREFIX,
if (memcmp(key.data, LDB_KV_GUID_KEY_PREFIX,
sizeof(LDB_KV_GUID_KEY_PREFIX) - 1) == 0) {
return true;
}
@ -90,17 +90,17 @@ bool ldb_kv_key_is_record(TDB_DATA key)
}
/*
form a TDB_DATA for a record key
form a ldb_val for a record key
caller frees
note that the key for a record can depend on whether the
dn refers to a case sensitive index record or not
*/
TDB_DATA ldb_kv_key_dn(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn)
struct ldb_val ldb_kv_key_dn(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn)
{
TDB_DATA key;
struct ldb_val key;
char *key_str = NULL;
const char *dn_folded = NULL;
@ -131,15 +131,15 @@ TDB_DATA ldb_kv_key_dn(struct ldb_module *module,
goto failed;
}
key.dptr = (uint8_t *)key_str;
key.dsize = strlen(key_str) + 1;
key.data = (uint8_t *)key_str;
key.length = strlen(key_str) + 1;
return key;
failed:
errno = ENOMEM;
key.dptr = NULL;
key.dsize = 0;
key.data = NULL;
key.length = 0;
return key;
}
@ -147,17 +147,17 @@ failed:
int ldb_kv_guid_to_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
const struct ldb_val *GUID_val,
TDB_DATA *key)
struct ldb_val *key)
{
const char *GUID_prefix = LDB_KV_GUID_KEY_PREFIX;
const int GUID_prefix_len = sizeof(LDB_KV_GUID_KEY_PREFIX) - 1;
if (key->dsize != (GUID_val->length+GUID_prefix_len)) {
if (key->length != (GUID_val->length+GUID_prefix_len)) {
return LDB_ERR_OPERATIONS_ERROR;
}
memcpy(key->dptr, GUID_prefix, GUID_prefix_len);
memcpy(&key->dptr[GUID_prefix_len],
memcpy(key->data, GUID_prefix, GUID_prefix_len);
memcpy(&key->data[GUID_prefix_len],
GUID_val->data, GUID_val->length);
return LDB_SUCCESS;
}
@ -170,7 +170,7 @@ int ldb_kv_idx_to_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
TALLOC_CTX *mem_ctx,
const struct ldb_val *idx_val,
TDB_DATA *key)
struct ldb_val *key)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
struct ldb_dn *dn;
@ -190,7 +190,7 @@ int ldb_kv_idx_to_key(struct ldb_module *module,
/* form the key */
*key = ldb_kv_key_dn(module, mem_ctx, dn);
TALLOC_FREE(dn);
if (!key->dptr) {
if (!key->data) {
return ldb_module_oom(module);
}
return LDB_SUCCESS;
@ -204,14 +204,14 @@ int ldb_kv_idx_to_key(struct ldb_module *module,
note that the key for a record can depend on whether a
GUID index is in use, or the DN is used as the key
*/
TDB_DATA ldb_kv_key_msg(struct ldb_module *module,
struct ldb_val ldb_kv_key_msg(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const struct ldb_message *msg)
{
void *data = ldb_module_get_private(module);
struct ldb_kv_private *ldb_kv =
talloc_get_type(data, struct ldb_kv_private);
TDB_DATA key;
struct ldb_val key;
const struct ldb_val *guid_val;
int ret;
@ -233,27 +233,27 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module,
ldb_kv->cache->GUID_index_attribute,
ldb_dn_get_linearized(msg->dn));
errno = EINVAL;
key.dptr = NULL;
key.dsize = 0;
key.data = NULL;
key.length = 0;
return key;
}
/* In this case, allocate with talloc */
key.dptr = talloc_size(mem_ctx, LDB_KV_GUID_KEY_SIZE);
if (key.dptr == NULL) {
key.data = talloc_size(mem_ctx, LDB_KV_GUID_KEY_SIZE);
if (key.data == NULL) {
errno = ENOMEM;
key.dptr = NULL;
key.dsize = 0;
key.data = NULL;
key.length = 0;
return key;
}
key.dsize = talloc_get_size(key.dptr);
key.length = talloc_get_size(key.data);
ret = ldb_kv_guid_to_key(module, ldb_kv, guid_val, &key);
if (ret != LDB_SUCCESS) {
errno = EINVAL;
key.dptr = NULL;
key.dsize = 0;
key.data = NULL;
key.length = 0;
return key;
}
return key;
@ -353,8 +353,7 @@ int ldb_kv_store(struct ldb_module *module,
void *data = ldb_module_get_private(module);
struct ldb_kv_private *ldb_kv =
talloc_get_type(data, struct ldb_kv_private);
TDB_DATA tdb_key;
struct ldb_val ldb_key;
struct ldb_val key;
struct ldb_val ldb_data;
int ret = LDB_SUCCESS;
TALLOC_CTX *key_ctx = talloc_new(module);
@ -368,8 +367,8 @@ int ldb_kv_store(struct ldb_module *module,
return LDB_ERR_UNWILLING_TO_PERFORM;
}
tdb_key = ldb_kv_key_msg(module, key_ctx, msg);
if (tdb_key.dptr == NULL) {
key = ldb_kv_key_msg(module, key_ctx, msg);
if (key.data == NULL) {
TALLOC_FREE(key_ctx);
return LDB_ERR_OTHER;
}
@ -381,10 +380,7 @@ int ldb_kv_store(struct ldb_module *module,
return LDB_ERR_OTHER;
}
ldb_key.data = tdb_key.dptr;
ldb_key.length = tdb_key.dsize;
ret = ldb_kv->kv_ops->store(ldb_kv, ldb_key, ldb_data, flgs);
ret = ldb_kv->kv_ops->store(ldb_kv, key, ldb_data, flgs);
if (ret != 0) {
bool is_special = ldb_dn_is_special(msg->dn);
ret = ldb_kv->kv_ops->error(ldb_kv);
@ -587,8 +583,7 @@ int ldb_kv_delete_noindex(struct ldb_module *module,
void *data = ldb_module_get_private(module);
struct ldb_kv_private *ldb_kv =
talloc_get_type(data, struct ldb_kv_private);
struct ldb_val ldb_key;
TDB_DATA tdb_key;
struct ldb_val key;
int ret;
TALLOC_CTX *tdb_key_ctx = talloc_new(module);
@ -601,16 +596,13 @@ int ldb_kv_delete_noindex(struct ldb_module *module,
return LDB_ERR_UNWILLING_TO_PERFORM;
}
tdb_key = ldb_kv_key_msg(module, tdb_key_ctx, msg);
if (!tdb_key.dptr) {
key = ldb_kv_key_msg(module, tdb_key_ctx, msg);
if (!key.data) {
TALLOC_FREE(tdb_key_ctx);
return LDB_ERR_OTHER;
}
ldb_key.data = tdb_key.dptr;
ldb_key.length = tdb_key.dsize;
ret = ldb_kv->kv_ops->delete (ldb_kv, ldb_key);
ret = ldb_kv->kv_ops->delete (ldb_kv, key);
TALLOC_FREE(tdb_key_ctx);
if (ret != 0) {
@ -1235,7 +1227,7 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
struct ldb_request *req = ctx->req;
struct ldb_message *msg;
int ret = LDB_SUCCESS;
TDB_DATA tdb_key, tdb_key_old;
struct ldb_val key, key_old;
struct ldb_dn *db_dn;
ldb_request_set_state(req, LDB_ASYNC_PENDING);
@ -1266,16 +1258,16 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
* Even in GUID index mode we use ltdb_key_dn() as we are
* trying to figure out if this is just a case rename
*/
tdb_key = ldb_kv_key_dn(module, msg, req->op.rename.newdn);
if (!tdb_key.dptr) {
key = ldb_kv_key_dn(module, msg, req->op.rename.newdn);
if (!key.data) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
tdb_key_old = ldb_kv_key_dn(module, msg, req->op.rename.olddn);
if (!tdb_key_old.dptr) {
key_old = ldb_kv_key_dn(module, msg, req->op.rename.olddn);
if (!key_old.data) {
talloc_free(msg);
talloc_free(tdb_key.dptr);
talloc_free(key.data);
return LDB_ERR_OPERATIONS_ERROR;
}
@ -1283,8 +1275,8 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
* Only declare a conflict if the new DN already exists,
* and it isn't a case change on the old DN
*/
if (tdb_key_old.dsize != tdb_key.dsize
|| memcmp(tdb_key.dptr, tdb_key_old.dptr, tdb_key.dsize) != 0) {
if (key_old.length != key.length
|| memcmp(key.data, key_old.data, key.length) != 0) {
ret = ldb_kv_search_base(
module, msg, req->op.rename.newdn, &db_dn);
if (ret == LDB_SUCCESS) {
@ -1302,14 +1294,14 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
ldb_dn_get_linearized(req->op.rename.newdn));
}
if (ret != LDB_SUCCESS) {
talloc_free(tdb_key_old.dptr);
talloc_free(tdb_key.dptr);
talloc_free(key_old.data);
talloc_free(key.data);
talloc_free(msg);
return ret;
}
talloc_free(tdb_key_old.dptr);
talloc_free(tdb_key.dptr);
talloc_free(key_old.data);
talloc_free(key.data);
/* Always delete first then add, to avoid conflicts with
* unique indexes. We rely on the transaction to make this

View File

@ -204,7 +204,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
TDB_DATA *tdb_key);
struct ldb_val *key);
/*
* The following definitions come from lib/ldb/ldb_key_value/ldb_kv_search.c
@ -219,7 +219,7 @@ int ldb_kv_search_base(struct ldb_module *module,
struct ldb_dn **ret_dn);
int ldb_kv_search_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
struct TDB_DATA tdb_key,
const struct ldb_val ldb_key,
struct ldb_message *msg,
unsigned int unpack_flags);
int ldb_kv_filter_attrs(TALLOC_CTX *mem_ctx,
@ -234,22 +234,22 @@ int ldb_kv_search(struct ldb_kv_context *ctx);
* Determine if this key could hold a record. We allow the new GUID
* index, the old DN index and a possible future ID=
*/
bool ldb_kv_key_is_record(TDB_DATA key);
TDB_DATA ldb_kv_key_dn(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn);
TDB_DATA ldb_kv_key_msg(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const struct ldb_message *msg);
bool ldb_kv_key_is_record(struct ldb_val key);
struct ldb_val ldb_kv_key_dn(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn);
struct ldb_val ldb_kv_key_msg(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
const struct ldb_message *msg);
int ldb_kv_guid_to_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
const struct ldb_val *GUID_val,
TDB_DATA *key);
struct ldb_val *key);
int ldb_kv_idx_to_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
TALLOC_CTX *mem_ctx,
const struct ldb_val *idx_val,
TDB_DATA *key);
struct ldb_val *key);
int ldb_kv_store(struct ldb_module *module,
const struct ldb_message *msg,
int flgs);

View File

@ -483,7 +483,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
TDB_DATA *tdb_key)
struct ldb_val *ldb_key)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
int ret;
@ -529,9 +529,9 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
index = -1;
for (i=0; i < list->count; i++) {
uint8_t guid_key[LDB_KV_GUID_KEY_SIZE];
TDB_DATA key = {
.dptr = guid_key,
.dsize = sizeof(guid_key)
struct ldb_val key = {
.data = guid_key,
.length = sizeof(guid_key)
};
const int flags = LDB_UNPACK_DATA_FLAG_NO_ATTRS;
struct ldb_message *rec = ldb_msg_new(ldb);
@ -550,8 +550,8 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
ret =
ldb_kv_search_key(module, ldb_kv, key, rec, flags);
if (key.dptr != guid_key) {
TALLOC_FREE(key.dptr);
if (key.data != guid_key) {
TALLOC_FREE(key.data);
}
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/*
@ -592,8 +592,8 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
}
}
/* The tdb_key memory is allocated by the caller */
ret = ldb_kv_guid_to_key(module, ldb_kv, &list->dn[index], tdb_key);
/* The ldb_key memory is allocated by the caller */
ret = ldb_kv_guid_to_key(module, ldb_kv, &list->dn[index], ldb_key);
TALLOC_FREE(list);
if (ret != LDB_SUCCESS) {
@ -1753,7 +1753,7 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
unsigned int i;
unsigned int num_keys = 0;
uint8_t previous_guid_key[LDB_KV_GUID_KEY_SIZE] = {};
TDB_DATA *keys = NULL;
struct ldb_val *keys = NULL;
/*
* We have to allocate the key list (rather than just walk the
@ -1761,7 +1761,7 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
* (by modifying an indexed attribute hosted in the in-memory
* index cache!)
*/
keys = talloc_array(ac, TDB_DATA, dn_list->count);
keys = talloc_array(ac, struct ldb_val, dn_list->count);
if (keys == NULL) {
return ldb_module_oom(ac->module);
}
@ -1785,13 +1785,13 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
return ldb_module_oom(ac->module);
}
for (i = 0; i < dn_list->count; i++) {
keys[i].dptr = key_values[i].guid_key;
keys[i].dsize = sizeof(key_values[i].guid_key);
keys[i].data = key_values[i].guid_key;
keys[i].length = sizeof(key_values[i].guid_key);
}
} else {
for (i = 0; i < dn_list->count; i++) {
keys[i].dptr = NULL;
keys[i].dsize = 0;
keys[i].data = NULL;
keys[i].length = 0;
}
}
@ -1818,13 +1818,13 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
*/
if (memcmp(previous_guid_key,
keys[num_keys].dptr,
keys[num_keys].data,
sizeof(previous_guid_key)) == 0) {
continue;
}
memcpy(previous_guid_key,
keys[num_keys].dptr,
keys[num_keys].data,
sizeof(previous_guid_key));
}
num_keys++;
@ -2187,9 +2187,9 @@ static int ldb_kv_index_add1(struct ldb_module *module,
int i;
for (i=0; i < list->count; i++) {
uint8_t guid_key[LDB_KV_GUID_KEY_SIZE];
TDB_DATA key = {
.dptr = guid_key,
.dsize = sizeof(guid_key)
struct ldb_val key = {
.data = guid_key,
.length = sizeof(guid_key)
};
const int flags = LDB_UNPACK_DATA_FLAG_NO_ATTRS;
struct ldb_message *rec = ldb_msg_new(ldb);
@ -2207,8 +2207,8 @@ static int ldb_kv_index_add1(struct ldb_module *module,
ret =
ldb_kv_search_key(module, ldb_kv, key, rec, flags);
if (key.dptr != guid_key) {
TALLOC_FREE(key.dptr);
if (key.data != guid_key) {
TALLOC_FREE(key.data);
}
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
/*
@ -2849,7 +2849,7 @@ static int delete_index(struct ldb_kv_private *ldb_kv,
traversal function that adds @INDEX records during a re index TODO wrong comment
*/
static int re_key(struct ldb_kv_private *ldb_kv,
struct ldb_val ldb_key,
struct ldb_val key,
struct ldb_val val,
void *state)
{
@ -2860,17 +2860,13 @@ static int re_key(struct ldb_kv_private *ldb_kv,
struct ldb_message *msg;
unsigned int nb_elements_in_db;
int ret;
TDB_DATA key2;
struct ldb_val key2;
bool is_record;
TDB_DATA key = {
.dptr = ldb_key.data,
.dsize = ldb_key.length
};
ldb = ldb_module_get_ctx(module);
if (key.dsize > 4 &&
memcmp(key.dptr, "DN=@", 4) == 0) {
if (key.length > 4 &&
memcmp(key.data, "DN=@", 4) == 0) {
return 0;
}
@ -2901,8 +2897,8 @@ static int re_key(struct ldb_kv_private *ldb_kv,
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Refusing to re-index as GUID "
"key %*.*s with no DN\n",
(int)key.dsize, (int)key.dsize,
(char *)key.dptr);
(int)key.length, (int)key.length,
(char *)key.data);
talloc_free(msg);
return -1;
}
@ -2911,23 +2907,19 @@ static int re_key(struct ldb_kv_private *ldb_kv,
insensitivity of an element changing, or a change from DN
to GUID keys */
key2 = ldb_kv_key_msg(module, msg, msg);
if (key2.dptr == NULL) {
if (key2.data == NULL) {
/* probably a corrupt record ... darn */
ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s",
ldb_dn_get_linearized(msg->dn));
talloc_free(msg);
return 0;
}
if (key.dsize != key2.dsize ||
(memcmp(key.dptr, key2.dptr, key.dsize) != 0)) {
struct ldb_val ldb_key2 = {
.data = key2.dptr,
.length = key2.dsize
};
if (key.length != key2.length ||
(memcmp(key.data, key2.data, key.length) != 0)) {
ldb_kv->kv_ops->update_in_iterate(
ldb_kv, ldb_key, ldb_key2, val, ctx);
ldb_kv, key, key2, val, ctx);
}
talloc_free(key2.dptr);
talloc_free(key2.data);
talloc_free(msg);
@ -2945,7 +2937,7 @@ static int re_key(struct ldb_kv_private *ldb_kv,
traversal function that adds @INDEX records during a re index
*/
static int re_index(struct ldb_kv_private *ldb_kv,
struct ldb_val ldb_key,
struct ldb_val key,
struct ldb_val val,
void *state)
{
@ -2955,17 +2947,13 @@ static int re_index(struct ldb_kv_private *ldb_kv,
struct ldb_module *module = ctx->module;
struct ldb_message *msg;
unsigned int nb_elements_in_db;
TDB_DATA key = {
.dptr = ldb_key.data,
.dsize = ldb_key.length
};
int ret;
bool is_record;
ldb = ldb_module_get_ctx(module);
if (key.dsize > 4 &&
memcmp(key.dptr, "DN=@", 4) == 0) {
if (key.length > 4 &&
memcmp(key.data, "DN=@", 4) == 0) {
return 0;
}
@ -2996,8 +2984,8 @@ static int re_index(struct ldb_kv_private *ldb_kv,
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Refusing to re-index as GUID "
"key %*.*s with no DN\n",
(int)key.dsize, (int)key.dsize,
(char *)key.dptr);
(int)key.length, (int)key.length,
(char *)key.data);
talloc_free(msg);
return -1;
}

View File

@ -235,7 +235,7 @@ static int ldb_kv_parse_data_unpack(struct ldb_val key,
*/
int ldb_kv_search_key(struct ldb_module *module,
struct ldb_kv_private *ldb_kv,
const struct TDB_DATA tdb_key,
const struct ldb_val ldb_key,
struct ldb_message *msg,
unsigned int unpack_flags)
{
@ -245,10 +245,6 @@ int ldb_kv_search_key(struct ldb_module *module,
.module = module,
.unpack_flags = unpack_flags
};
struct ldb_val ldb_key = {
.data = tdb_key.dptr,
.length = tdb_key.dsize
};
memset(msg, 0, sizeof(*msg));
@ -292,9 +288,9 @@ int ldb_kv_search_dn1(struct ldb_module *module,
talloc_get_type(data, struct ldb_kv_private);
int ret;
uint8_t guid_key[LDB_KV_GUID_KEY_SIZE];
TDB_DATA tdb_key = {
.dptr = guid_key,
.dsize = sizeof(guid_key)
struct ldb_val key = {
.data = guid_key,
.length = sizeof(guid_key)
};
TALLOC_CTX *tdb_key_ctx = NULL;
@ -307,8 +303,8 @@ int ldb_kv_search_dn1(struct ldb_module *module,
}
/* form the key */
tdb_key = ldb_kv_key_dn(module, tdb_key_ctx, dn);
if (!tdb_key.dptr) {
key = ldb_kv_key_dn(module, tdb_key_ctx, dn);
if (!key.data) {
TALLOC_FREE(tdb_key_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
@ -320,13 +316,13 @@ int ldb_kv_search_dn1(struct ldb_module *module,
* used for internal memory.
*
*/
ret = ldb_kv_key_dn_from_idx(module, ldb_kv, msg, dn, &tdb_key);
ret = ldb_kv_key_dn_from_idx(module, ldb_kv, msg, dn, &key);
if (ret != LDB_SUCCESS) {
return ret;
}
}
ret = ldb_kv_search_key(module, ldb_kv, tdb_key, msg, unpack_flags);
ret = ldb_kv_search_key(module, ldb_kv, key, msg, unpack_flags);
TALLOC_FREE(tdb_key_ctx);
@ -504,15 +500,11 @@ static int search_func(struct ldb_kv_private *ldb_kv,
int ret;
bool matched;
unsigned int nb_elements_in_db;
TDB_DATA tdb_key = {
.dptr = key.data,
.dsize = key.length
};
ac = talloc_get_type(state, struct ldb_kv_context);
ldb = ldb_module_get_ctx(ac->module);
if (ldb_kv_key_is_record(tdb_key) == false) {
if (ldb_kv_key_is_record(key) == false) {
return 0;
}