static void mdb_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 = mdb_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; /* ITS#8678 FIXME * If using 32bit hashes, or substring index, must account for * possible index collisions. If no substring index, and using * 64bit hashes, assume we don't need to check for collisions. * * In 2.5 use refcounts and avoid all of this mess. */ /* FIXME: use t1ha2_64() */ #ifdef LUTIL_HASH64_BYTES const int hash32width = !slap_hash64(-1); #else const int hash32width = 1; #endif if (hash32width || (ai->ai_indexmask & SLAP_INDEX_SUBSTR)) { /* Find all other attrs that index to same slot */ for ( ap = newattrs; ap; ap = ap->a_next ) { ai = mdb_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; } } }
static void mdb_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 = mdb_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 = mdb_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 mdb_index_param( Backend *be, AttributeDescription *desc, int ftype, MDB_dbi *dbip, slap_mask_t *maskp, struct berval *prefixp ) { AttrInfo *ai; slap_mask_t mask, type = 0; ai = mdb_index_mask( be, desc, prefixp ); if ( !ai ) { #ifdef MDB_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; } mdb_monitor_idx_add( be->be_private, desc, type ); #endif /* MDB_MONITOR_IDX */ return LDAP_INAPPROPRIATE_MATCHING; } mask = ai->ai_indexmask; switch( ftype ) { case LDAP_FILTER_PRESENT: type = SLAP_INDEX_PRESENT; if( IS_SLAP_INDEX( mask, type ) ) { *prefixp = presence_key[0]; goto done; } break; case LDAP_FILTER_APPROX: type = SLAP_INDEX_APPROX; if ( desc->ad_type->sat_approx ) { if( IS_SLAP_INDEX( mask, type ) ) { 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, type ) ) { goto done; } break; case LDAP_FILTER_SUBSTRINGS: type = SLAP_INDEX_SUBSTR; if( IS_SLAP_INDEX( mask, type ) ) { goto done; } break; default: return LDAP_OTHER; } #ifdef MDB_MONITOR_IDX mdb_monitor_idx_add( be->be_private, desc, type ); #endif /* MDB_MONITOR_IDX */ return LDAP_INAPPROPRIATE_MATCHING; done: *dbip = ai->ai_dbi; *maskp = mask; return LDAP_SUCCESS; }