/* store it -- don't override */
rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n",
+ db_strerror(rc), rc, 0 );
goto done;
}
pdn, key.size - 1 );
rc = bdb_idl_insert_key( be, db, txn, &key, id );
- free( pdn );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
+ pdn, rc, 0 );
+ free( pdn );
goto done;
}
+ free( pdn );
}
}
rc = bdb_idl_insert_key( be, db, txn, &key, id );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
+ subtree[i], rc, 0 );
+ charray_free( subtree );
goto done;
}
}
/* store it -- don't override */
rc = db->del( db, txn, &key, 0 );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n",
+ db_strerror(rc), rc, 0 );
goto done;
}
pdn, key.size - 1 );
rc = bdb_idl_delete_key( be, db, txn, &key, id );
- free( pdn );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
+ pdn, rc, 0 );
+ free( pdn );
goto done;
}
+ free( pdn );
}
}
rc = bdb_idl_delete_key( be, db, txn, &key, id );
if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
+ subtree[i], rc, 0 );
+ charray_free( subtree );
goto done;
}
}
int bdb_idl_search( ID *ids, ID id )
{
+#if BDB_IDL_BINARY_SEARCH
/*
* binary search of id in ids
* if found, returns position of id
} else {
return cursor + 1;
}
+#else
+ /* linear search */
+ int i;
+ for( i=1; i<=ids[0]; i++ ) {
+ if( id <= ids[i] ) {
+ return i;
+ }
+ }
+ return i;
+#endif
}
static int idl_insert( ID *ids, ID id )
} else {
rc = idl_insert( ids, id );
- if( rc != 0 ) return rc;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_idl_insert_key: idl_insert failed (%d)\n",
+ rc, 0, 0 );
+ return rc;
+ }
data.size = (ids[0]+1) * sizeof( ID );
}
} else {
rc = idl_delete( ids, id );
- if( rc != 0 ) return rc;
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "=> bdb_idl_insert_key: idl_insert failed (%d)\n",
+ rc, 0, 0 );
+ return rc;
+ }
if( BDB_IS_ALLIDS(ids) ) {
/* delete the key */