/* tools.c - tools for slap tools */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2000-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
*/
#include "portable.h"
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;
+
for ( i=0; i<nholes; i++) {
if ( holes[i].id == e->e_id ) {
int j;