]> git.sur5r.net Git - openldap/commitdiff
improve candidate selection when filtering by objectClass
authorPierangelo Masarati <ando@openldap.org>
Wed, 22 Sep 2004 23:17:32 +0000 (23:17 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 22 Sep 2004 23:17:32 +0000 (23:17 +0000)
servers/slapd/back-sql/schema-map.c
servers/slapd/back-sql/search.c

index 846bfd5a22287eb002fad61f68d3559c9d3969a2..cd539e8316fc8c272b8065bae29fc6257837ea99 100644 (file)
@@ -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,
index 757e8acd840a7985581edbe67be9a837190d578c..52d930b0a982f85e34d2d3eb3e318e16b9b439de 100644 (file)
@@ -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