goto return_results;
}
- /* This is the first add to a root DB, need to make the suffix glue */
- if ( op->o_bd->be_nsuffix[0].bv_len == 0 && ei->bei_id == 0 ) {
- Entry e_root = {0};
- e_root.e_name.bv_val = "";
- e_root.e_nname.bv_val = "";
- e_root.e_id = 1;
- rs->sr_err = bdb_dn2id_add( op, lt2, ei, &e_root );
-
- /* Just give up on any failure. */
- if ( rs->sr_err ) {
- rs->sr_err = LDAP_OTHER;
- goto return_results;
- }
-
- /* Get a new ID for the actual entry */
- if ( op->oq_add.rs_e->e_id == 1 ) {
- rs->sr_err = bdb_next_id( op->o_bd, NULL, &op->oq_add.rs_e->e_id );
- if (rs->sr_err) {
- rs->sr_err = LDAP_OTHER;
- goto return_results;
- }
- }
-
- /* Get new EntryInfo */
- rs->sr_err = bdb_dn2entry( op, ltid, &op->ora_e->e_nname, &ei,
- 1, locker, &lock );
- if (rs->sr_err != DB_NOTFOUND) {
- rs->sr_err = LDAP_OTHER;
- goto return_results;
- }
- }
-
/* dn2id index */
rs->sr_err = bdb_dn2id_add( op, lt2, ei, op->oq_add.rs_e );
if ( rs->sr_err != 0 ) {
ptr = ndn->bv_val + ndn->bv_len - op->o_bd->be_nsuffix[0].bv_len;
ei.bei_nrdn.bv_val = ptr;
ei.bei_nrdn.bv_len = op->o_bd->be_nsuffix[0].bv_len;
+ /* Skip to next rdn if suffix is empty */
+ if ( ei.bei_nrdn.bv_len == 0 ) {
+ for (ptr = ei.bei_nrdn.bv_val - 2; ptr > ndn->bv_val
+ && !DN_SEPARATOR(*ptr); ptr--) /* empty */;
+ if ( ptr >= ndn->bv_val ) {
+ if (DN_SEPARATOR(*ptr)) ptr++;
+ ei.bei_nrdn.bv_len = ei.bei_nrdn.bv_val - ptr;
+ ei.bei_nrdn.bv_val = ptr;
+ }
+ }
eip = &bdb->bi_cache.c_dntree;
}
ei_root.bei_e = &e_root;
ei_root.bei_parent = &ei_root;
e_root.e_private = &ei_root;
- e_root.e_id = 1;
+ e_root.e_id = 0;
e_root.e_nname.bv_val="";
e_root.e_name.bv_val="";
ei = &ei_root;
#endif
case LDAP_SCOPE_SUBTREE: {
EntryInfo *tmp;
- for (tmp = BEI(e); tmp->bei_parent;
+ for (tmp = BEI(e); tmp;
tmp = tmp->bei_parent ) {
if ( tmp->bei_id == base.e_id ) {
scopeok = 1;
if( nholes ) {
unsigned i;
- int fail=0, warn=1;
+ fprintf( stderr, "Error, entries missing!\n");
for (i=0; i<nholes; i++) {
- if (holes[i].dn.bv_len) {
- fail=1;
- if (warn) {
- fprintf( stderr, "Error, entries missing!\n");
- warn=0;
- }
- fprintf(stderr, " entry %ld: %s\n",
- holes[i].id, holes[i].dn.bv_val);
- }
+ fprintf(stderr, " entry %ld: %s\n",
+ holes[i].id, holes[i].dn.bv_val);
}
- if (fail) return -1;
+ return -1;
}
return 0;
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_nname = dn;
+ e->e_name = dn;
+ e->e_nname = ndn;
if ( rc ) {
return rc;
}
}
nhmax *= 2;
}
- ber_dupbv( &holes[nholes].dn, &dn );
+ ber_dupbv( &holes[nholes].dn, &ndn );
holes[nholes++].id = e->e_id;
}
} else if ( !hole ) {