From: Pierangelo Masarati Date: Wed, 22 Sep 2004 23:17:32 +0000 (+0000) Subject: improve candidate selection when filtering by objectClass X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~512 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0055675bfc8f9ce937c9189d072a438754b46b18;p=openldap improve candidate selection when filtering by objectClass --- diff --git a/servers/slapd/back-sql/schema-map.c b/servers/slapd/back-sql/schema-map.c index 846bfd5a22..cd539e8316 100644 --- a/servers/slapd/back-sql/schema-map.c +++ b/servers/slapd/back-sql/schema-map.c @@ -247,14 +247,14 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map ) oc_map->bom_oc->soc_cname.bv_val, 0 ); } - /* FIXME: whe need to correct the objectClass join_where + /* FIXME: we need to correct the objectClass join_where * after the attribute query is built */ ch_free( at_map->bam_join_where.bv_val ); BER_BVZERO( &bb.bb_val ); bb.bb_len = 0; backsql_strfcat( &bb, "lbcblb", - (ber_len_t)STRLENOF( "ldap_entries.keyval=" ), - "ldap_entries.keyval=", + (ber_len_t)STRLENOF( /* "ldap_entries.id=ldap_entry_objclasses.entry_id AND " */ "ldap_entries.keyval=" ), + /* "ldap_entries.id=ldap_entry_objclasses.entry_id AND " */ "ldap_entries.keyval=", &oc_map->bom_keytbl, '.', &oc_map->bom_keycol, diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 757e8acd84..52d930b0a9 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -574,8 +574,8 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f ) backsql_merge_from_tbls( bsi, &ldap_entry_objclasses ); backsql_strfcat( &bsi->bsi_flt_where, "lbl", - (ber_len_t)STRLENOF( "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entry_objclasses.oc_name='" /* ') */ ), - "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id and ldap_entry_objclasses.oc_name='" /* ') */, + (ber_len_t)STRLENOF( "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */ ), + "1=1 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */, &bsi->bsi_oc->bom_oc->soc_cname, (ber_len_t)STRLENOF( /* (' */ "')" ), /* (' */ "')" ); @@ -876,6 +876,23 @@ equality_match:; break; } + /* NOTE: this is required by objectClass inheritance + * and auxiliary objectClass use in filters for slightly + * more efficient candidate selection. */ + /* FIXME: a bit too many specializations to deal with + * very specific cases... */ + if ( at->bam_ad == slap_schema.si_ad_objectClass + || at->bam_ad == slap_schema.si_ad_structuralObjectClass ) + { + backsql_strfcat( &bsi->bsi_flt_where, "lbl", + (ber_len_t)STRLENOF( "(ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */ ), + "(ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */, + filter_value, + (ber_len_t)STRLENOF( /* (' */ "')" ), + /* (' */ "')" ); + break; + } + /* * maybe we should check type of at->sel_expr here somehow, * to know whether upper_func is applicable, but for now