- /* delete indices for old attributes */
- rc = bdb_index_entry_del( be, tid, e, save_attrs);
- if ( rc != LDAP_SUCCESS ) {
- attrs_free( e->e_attrs );
- e->e_attrs = save_attrs;
- Debug( LDAP_DEBUG_ANY, "entry index delete failed!\n",
- 0, 0, 0 );
- return rc;
+ /* update the indices of the modified attributes */
+
+ /* start with deleting the old index entries */
+ for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
+ if ( ap->a_flags & SLAP_ATTR_IXDEL ) {
+ rc = bdb_index_values( be, tid, ap->a_desc, ap->a_vals,
+ e->e_id, SLAP_INDEX_DELETE_OP );
+ if ( rc != LDAP_SUCCESS ) {
+ attrs_free( e->e_attrs );
+ e->e_attrs = save_attrs;
+ Debug( LDAP_DEBUG_ANY,
+ "Attribute index delete failure",
+ 0, 0, 0 );
+ return rc;
+ }
+ ap->a_flags &= ~SLAP_ATTR_IXDEL;
+ }