]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/filterindex.c
document option '-F'
[openldap] / servers / slapd / back-bdb / filterindex.c
index 73bc1dc63642570634877cbbdc603f5c870b87dd..ea997d1b35bca9bac560ced2e892e1bf2624e263 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2004 The OpenLDAP Foundation.
+ * Copyright 2000-2005 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -21,6 +21,9 @@
 
 #include "back-bdb.h"
 #include "idl.h"
+#ifdef LDAP_COMP_MATCH
+#include <component.h>
+#endif
 
 static int presence_candidates(
        Operation *op,
@@ -65,6 +68,24 @@ ext_candidates(
         ID *ids,
         ID *tmp,
         ID *stack);
+
+static int
+comp_candidates (
+       Operation *op,
+       MatchingRuleAssertion *mra,
+       ComponentFilter *f,
+       ID *ids,
+       ID *tmp,
+       ID *stack);
+
+static int
+ava_comp_candidates (
+               Operation *op,
+               AttributeAssertion *ava,
+               AttributeAliasing *aa,
+               ID *ids,
+               ID *tmp,
+               ID *stack);
 #endif
 
 int
@@ -76,6 +97,9 @@ bdb_filter_candidates(
        ID *stack )
 {
        int rc = 0;
+#ifdef LDAP_COMP_MATCH
+       AttributeAliasing *aa;
+#endif
        Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 );
 
        switch ( f->f_choice ) {
@@ -105,7 +129,15 @@ bdb_filter_candidates(
 
        case LDAP_FILTER_EQUALITY:
                Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
-               rc = equality_candidates( op, f->f_ava, ids, tmp );
+#ifdef LDAP_COMP_MATCH
+               if ( is_aliased_attribute && ( aa = is_aliased_attribute ( f->f_ava->aa_desc ) ) ) {
+                       rc = ava_comp_candidates ( op, f->f_ava, aa, ids, tmp, stack );
+               }
+               else
+#endif
+               {
+                       rc = equality_candidates( op, f->f_ava, ids, tmp );
+               }
                break;
 
        case LDAP_FILTER_APPROX:
@@ -192,7 +224,6 @@ comp_list_candidates(
        ID *tmp,
        ID *save )
 {
-       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        int rc = 0;
        ComponentFilter *f;
 
@@ -352,6 +383,29 @@ comp_equality_candidates (
         return( rc );
 }
 
+static int
+ava_comp_candidates (
+       Operation *op,
+       AttributeAssertion *ava,
+       AttributeAliasing *aa,
+       ID *ids,
+       ID *tmp,
+       ID *stack )
+{
+       MatchingRuleAssertion mra;
+       
+       mra.ma_rule = ava->aa_desc->ad_type->sat_equality;
+       if ( !mra.ma_rule ) {
+               struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
+               BDB_IDL_ALL( bdb, ids );
+               return 0;
+       }
+       mra.ma_desc = aa->aa_aliased_ad;
+       mra.ma_rule = ava->aa_desc->ad_type->sat_equality;
+       
+       return comp_candidates ( op, &mra, ava->aa_cf, ids, tmp, stack );
+}
+
 static int
 comp_candidates (
        Operation *op,
@@ -411,8 +465,12 @@ ext_candidates(
         * Currently Only Component Indexing for componentFilterMatch is supported
         * Indexing for an extensible filter is not supported yet
         */
-       if ( !mra->ma_cf )
+       if ( !mra->ma_cf ) {
+               struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
+               BDB_IDL_ALL( bdb, ids );
                return 0;
+       }
+
        return comp_candidates ( op, mra, mra->ma_cf, ids, tmp, stack);
 }
 #endif
@@ -426,7 +484,6 @@ list_candidates(
        ID *tmp,
        ID *save )
 {
-       struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        int rc = 0;
        Filter  *f;