int hole )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
- struct berval dn = e->e_nname;
- struct berval pdn;
+ struct berval dn = e->e_name;
+ struct berval ndn = e->e_nname;
+ struct berval pdn, npdn;
EntryInfo *ei = NULL;
int rc;
- rc = bdb_cache_find_ndn( op, tid, &dn, &ei );
+ if (ndn.bv_len == 0) return 0;
+
+ rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
if ( ei ) bdb_cache_entryinfo_unlock( ei );
if ( rc == DB_NOTFOUND ) {
- if ( be_issuffix( op->o_bd, &dn ) ) {
- pdn = slap_empty_bv;
- } else {
+ if ( !be_issuffix( op->o_bd, &ndn ) ) {
dnParent( &dn, &pdn );
- e->e_nname = pdn;
+ dnParent( &ndn, &npdn );
+ e->e_name = pdn;
+ e->e_nname = npdn;
rc = bdb_tool_next_id( op, tid, e, text, 1 );
+ e->e_name = dn;
+ e->e_nname = ndn;
if ( rc ) {
return rc;
}
#endif
return rc;
}
- e->e_nname = dn;
rc = bdb_dn2id_add( op, tid, ei, e );
if ( rc ) {
snprintf( text->bv_val, text->bv_len,
} else if ( hole ) {
if ( nholes == nhmax - 1 ) {
if ( holes == hbuf ) {
- holes = ch_malloc( nhmax * sizeof(ID) * 2 );
+ holes = ch_malloc( nhmax * sizeof(dn_id) * 2 );
AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
} else {
- holes = ch_realloc( holes, nhmax * sizeof(ID) * 2 );
+ holes = ch_realloc( holes, nhmax * sizeof(dn_id) * 2 );
}
nhmax *= 2;
}
- ber_dupbv( &holes[nholes].dn, &dn );
+ ber_dupbv( &holes[nholes].dn, &ndn );
holes[nholes++].id = e->e_id;
}
} else if ( !hole ) {
unsigned i;
e->e_id = ei->bei_id;
- rc = DB_KEYEXIST;
for ( i=0; i<nholes; i++) {
if ( holes[i].id == e->e_id ) {
for (j=i;j<nholes;j++) holes[j] = holes[j+1];
holes[j].id = 0;
nholes--;
- rc = 0;
break;
} else if ( holes[i].id > e->e_id ) {
break;