]> git.sur5r.net Git - openldap/commitdiff
ITS#2453, Fix filter candidate generation
authorHoward Chu <hyc@openldap.org>
Fri, 18 Apr 2003 03:36:52 +0000 (03:36 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 18 Apr 2003 03:36:52 +0000 (03:36 +0000)
servers/slapd/back-bdb/filterindex.c
servers/slapd/back-bdb/search.c

index 369b3f46b1a86ece8a3e615bad7b01d4978ac2d0..3b0ed135a384a05dcf2522f1ff39188297e90e29 100644 (file)
@@ -58,6 +58,10 @@ bdb_filter_candidates(
 #endif
 
        switch ( f->f_choice ) {
+       case SLAPD_FILTER_COMPUTED:
+               rc = 0;
+               break;
+
        case SLAPD_FILTER_DN_ONE:
 #ifdef NEW_LOGGING
                LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", 0, 0, 0 );
@@ -212,12 +216,8 @@ list_candidates(
        Debug( LDAP_DEBUG_FILTER, "=> bdb_list_candidates 0x%x\n", ftype, 0, 0 );
 #endif
 
-       if ( ftype == LDAP_FILTER_OR ) {
-               BDB_IDL_ALL( bdb, save );
-               BDB_IDL_ZERO( ids );
-       } else {
-               BDB_IDL_CPY( save, ids );
-       }
+       /* Copy so we can propagate pre-computed IDLs */
+       BDB_IDL_CPY( save, ids );
 
        for ( f = flist; f != NULL; f = f->f_next ) {
                rc = bdb_filter_candidates( op, f, save, tmp,
@@ -230,14 +230,22 @@ list_candidates(
                        }
                        break;
                }
+
                
                if ( ftype == LDAP_FILTER_AND ) {
-                       bdb_idl_intersection( ids, save );
+                       if ( f == flist ) {
+                               BDB_IDL_CPY( ids, save );
+                       } else {
+                               bdb_idl_intersection( ids, save );
+                       }
                        if( BDB_IDL_IS_ZERO( ids ) )
                                break;
                } else {
-                       bdb_idl_union( ids, save );
-                       BDB_IDL_ALL( bdb, save );
+                       if ( f == flist ) {
+                               BDB_IDL_CPY( ids, save );
+                       } else {
+                               bdb_idl_union( ids, save );
+                       }
                }
        }
 
@@ -509,7 +517,11 @@ equality_candidates(
                        break;
                }
 
-               bdb_idl_intersection( ids, tmp );
+               if ( i == 0 ) {
+                       BDB_IDL_CPY( ids, tmp );
+               } else {
+                       bdb_idl_intersection( ids, tmp );
+               }
 
                if( BDB_IDL_IS_ZERO( ids ) )
                        break;
@@ -674,7 +686,11 @@ approx_candidates(
                        break;
                }
 
-               bdb_idl_intersection( ids, tmp );
+               if ( i == 0 ) {
+                       BDB_IDL_CPY( ids, tmp );
+               } else {
+                       bdb_idl_intersection( ids, tmp );
+               }
 
                if( BDB_IDL_IS_ZERO( ids ) )
                        break;
@@ -833,7 +849,11 @@ substring_candidates(
                        break;
                }
 
-               bdb_idl_intersection( ids, tmp );
+               if ( i == 0 ) {
+                       BDB_IDL_CPY( ids, tmp );
+               } else {
+                       bdb_idl_intersection( ids, tmp );
+               }
 
                if( BDB_IDL_IS_ZERO( ids ) )
                        break;
index 046efa547130539124af21f77278c5736729e190..91d8c7e501742a21f038f71b1b7701bf0a05eafb 100644 (file)
@@ -164,7 +164,7 @@ static int search_aliases(
        af.f_next = NULL;
 
        /* Find all aliases in database */
-       BDB_IDL_ALL( bdb, aliases );
+       BDB_IDL_ZERO( aliases );
        rs->sr_err = bdb_filter_candidates( op, &af, aliases,
                curscop, visited );
        if (rs->sr_err != LDAP_SUCCESS) {
@@ -670,7 +670,7 @@ dn2entry_retry:
                rs->sr_err = base_candidate( op->o_bd, &base, candidates );
 
        } else {
-               BDB_IDL_ALL( bdb, candidates );
+               BDB_IDL_ZERO( candidates );
                BDB_IDL_ZERO( scopes );
                rs->sr_err = search_candidates( op, sop, rs, &base, locker, candidates, scopes );
        }
@@ -1521,7 +1521,7 @@ static int search_candidates(
        f.f_choice = LDAP_FILTER_AND;
        f.f_and = &nf;
        /* Dummy; we compute scope separately now */
-       nf.f_choice = LDAP_FILTER_NOT;
+       nf.f_choice = SLAPD_FILTER_COMPUTED;
        nf.f_next = xf.f_or == op->oq_search.rs_filter
                ? op->oq_search.rs_filter : &xf ;
        /* Filter depth increased again, adding dummy clause */
@@ -1534,7 +1534,7 @@ static int search_candidates(
                sf.f_ava = &aa_subentry;
                sf.f_av_desc = slap_schema.si_ad_objectClass;
                sf.f_av_value = bv_subentry;
-               sf.f_next = scopef.f_next;
+               sf.f_next = nf.f_next;
                nf.f_next = &sf;
        }
 #endif