/* Get the list of which indices apply to this attr */ int bdb_index_recset( struct bdb_info *bdb, Attribute *a, AttributeType *type, struct berval *tags, IndexRec *ir ) { int rc, slot; AttrList *al; if( type->sat_sup ) { /* recurse */ rc = bdb_index_recset( bdb, a, type->sat_sup, tags, ir ); if( rc ) return rc; } /* If this type has no AD, we've never used it before */ if( type->sat_ad ) { slot = bdb_attr_slot( bdb, type->sat_ad, NULL ); if ( slot >= 0 ) { ir[slot].ai = bdb->bi_attrs[slot]; al = ch_malloc( sizeof( AttrList )); al->attr = a; al->next = ir[slot].attrs; ir[slot].attrs = al; } } if( tags->bv_len ) { AttributeDescription *desc; desc = ad_find_tags( type, tags ); if( desc ) { slot = bdb_attr_slot( bdb, desc, NULL ); if ( slot >= 0 ) { ir[slot].ai = bdb->bi_attrs[slot]; al = ch_malloc( sizeof( AttrList )); al->attr = a; al->next = ir[slot].attrs; ir[slot].attrs = al; } } } return LDAP_SUCCESS; }
static int index_at_values( Operation *op, wt_ctx *wc, AttributeDescription *ad, AttributeType *type, struct berval *tags, BerVarray vals, ID id, int opid ) { int rc; slap_mask_t mask = 0; int ixop = opid; AttrInfo *ai = NULL; if ( opid == WT_INDEX_UPDATE_OP ) ixop = SLAP_INDEX_ADD_OP; if( type->sat_sup ) { /* recurse */ rc = index_at_values( op, wc, NULL, type->sat_sup, tags, vals, id, opid ); if( rc ) return rc; } /* If this type has no AD, we've never used it before */ if( type->sat_ad ) { ai = wt_attr_mask( op->o_bd->be_private, type->sat_ad ); if ( ai ) { #ifdef LDAP_COMP_MATCH /* component indexing */ if ( ai->ai_cr ) { ComponentReference *cr; for( cr = ai->ai_cr ; cr ; cr = cr->cr_next ) { rc = indexer( op, wc, cr->cr_ad, &type->sat_cname, cr->cr_nvals, id, ixop, cr->cr_indexmask ); } } #endif ad = type->sat_ad; /* If we're updating the index, just set the new bits that aren't * already in the old mask. */ if ( opid == WT_INDEX_UPDATE_OP ) mask = ai->ai_newmask & ~ai->ai_indexmask; else /* For regular updates, if there is a newmask use it. Otherwise * just use the old mask. */ mask = ai->ai_newmask ? ai->ai_newmask : ai->ai_indexmask; if( mask ) { rc = indexer( op, wc, ad, &type->sat_cname, vals, id, ixop, mask ); if( rc ) return rc; } } } if( tags->bv_len ) { AttributeDescription *desc; desc = ad_find_tags( type, tags ); if( desc ) { ai = wt_attr_mask( op->o_bd->be_private, desc ); if( ai ) { if ( opid == WT_INDEX_UPDATE_OP ) mask = ai->ai_newmask & ~ai->ai_indexmask; else mask = ai->ai_newmask ? ai->ai_newmask : ai->ai_indexmask; if ( mask ) { rc = indexer( op, wc, desc, &desc->ad_cname, vals, id, ixop, mask ); if( rc ) { return rc; } } } } } return LDAP_SUCCESS; }