static void bdb_modify_idxflags( Operation *op, AttributeDescription *desc, int got_delete, Attribute *newattrs, Attribute *oldattrs ) { struct berval ix_at; AttrInfo *ai; /* check if modified attribute was indexed * but not in case of NOOP... */ ai = bdb_index_mask( op->o_bd, desc, &ix_at ); if ( ai ) { if ( got_delete ) { Attribute *ap; struct berval ix2; ap = attr_find( oldattrs, desc ); if ( ap ) ap->a_flags |= SLAP_ATTR_IXDEL; /* Find all other attrs that index to same slot */ for ( ap = newattrs; ap; ap = ap->a_next ) { ai = bdb_index_mask( op->o_bd, ap->a_desc, &ix2 ); if ( ai && ix2.bv_val == ix_at.bv_val ) ap->a_flags |= SLAP_ATTR_IXADD; } } else { Attribute *ap; ap = attr_find( newattrs, desc ); if ( ap ) ap->a_flags |= SLAP_ATTR_IXADD; } } }
/* This function is only called when evaluating search filters. */ int bdb_index_param( Backend *be, AttributeDescription *desc, int ftype, DB **dbp, slap_mask_t *maskp, struct berval *prefixp ) { AttrInfo *ai; int rc; slap_mask_t mask, type = 0; DB *db; ai = bdb_index_mask( be, desc, prefixp ); if ( !ai ) { #ifdef BDB_MONITOR_IDX switch ( ftype ) { case LDAP_FILTER_PRESENT: type = SLAP_INDEX_PRESENT; break; case LDAP_FILTER_APPROX: type = SLAP_INDEX_APPROX; break; case LDAP_FILTER_EQUALITY: type = SLAP_INDEX_EQUALITY; break; case LDAP_FILTER_SUBSTRINGS: type = SLAP_INDEX_SUBSTR; break; default: return LDAP_INAPPROPRIATE_MATCHING; } bdb_monitor_idx_add( be->be_private, desc, type ); #endif /* BDB_MONITOR_IDX */ return LDAP_INAPPROPRIATE_MATCHING; } mask = ai->ai_indexmask; rc = bdb_db_cache( be, prefixp, &db ); if( rc != LDAP_SUCCESS ) { return rc; } switch( ftype ) { case LDAP_FILTER_PRESENT: type = SLAP_INDEX_PRESENT; if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { *prefixp = presence_key; goto done; } break; case LDAP_FILTER_APPROX: type = SLAP_INDEX_APPROX; if ( desc->ad_type->sat_approx ) { if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) { goto done; } break; } /* Use EQUALITY rule and index for approximate match */ /* fall thru */ case LDAP_FILTER_EQUALITY: type = SLAP_INDEX_EQUALITY; if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { goto done; } break; case LDAP_FILTER_SUBSTRINGS: type = SLAP_INDEX_SUBSTR; if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) { goto done; } break; default: return LDAP_OTHER; } #ifdef BDB_MONITOR_IDX bdb_monitor_idx_add( be->be_private, desc, type ); #endif /* BDB_MONITOR_IDX */ return LDAP_INAPPROPRIATE_MATCHING; done: *dbp = db; *maskp = mask; return LDAP_SUCCESS; }