]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/filterindex.c
More struct berval DN changes
[openldap] / servers / slapd / back-ldbm / filterindex.c
index 8732599d74840b7ff0e3b693ef11492ac56a4144..048050ca348c05e90690dc693a3de5c3bfb00a5d 100644 (file)
@@ -36,7 +36,7 @@ filter_candidates(
     Filter     *f
 )
 {
-       ID_BLOCK        *result, *tmp1, *tmp2;
+       ID_BLOCK        *result;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY, "filter_candidates: enter\n"));
@@ -135,7 +135,7 @@ filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
 #endif
 
-               result = idl_allids( be );
+               result = presence_candidates( be, f->f_desc );
                break;
 
        case LDAP_FILTER_LE:
@@ -146,7 +146,7 @@ filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
 #endif
 
-               result = idl_allids( be );
+               result = presence_candidates( be, f->f_desc );
                break;
 
        case LDAP_FILTER_AND:
@@ -179,11 +179,13 @@ filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 );
 #endif
 
-               tmp1 = idl_allids( be );
-               tmp2 = filter_candidates( be, f->f_not );
-               result = idl_notin( be, tmp1, tmp2 );
-               idl_free( tmp2 );
-               idl_free( tmp1 );
+               /*
+                * As candidates lists may contain entries which do
+                * not match the assertion, negation of the inner candidate
+                * list could result in matching entries be excluded from
+                * the returned candidate list.
+                */
+               result = idl_allids( be );
                break;
        }
 
@@ -210,7 +212,7 @@ presence_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
+       struct berval prefix = {0};
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@@ -219,9 +221,12 @@ presence_candidates(
        Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
 #endif
 
-
        idl = idl_allids( be );
 
+       if( desc == slap_schema.si_ad_objectClass ) {
+               return idl;
+       }
+
        rc = index_param( be, desc, LDAP_FILTER_PRESENT,
                &dbname, &mask, &prefix );
 
@@ -250,7 +255,6 @@ presence_candidates(
                        0, 0, 0 );
 #endif
 
-               ber_bvfree( prefix );
                return idl;
        }
 
@@ -267,15 +271,14 @@ presence_candidates(
                        dbname, LDBM_SUFFIX, 0 );
 #endif
 
-               ber_bvfree( prefix );
                return idl;
        }
 
-       if( prefix != NULL ) {
+       if( prefix.bv_val != NULL ) {
                idl_free( idl );
                idl = NULL;
 
-               rc = key_read( be, db, prefix, &idl );
+               rc = key_read( be, db, &prefix, &idl );
 
                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
@@ -302,7 +305,6 @@ presence_candidates(
        }
 
        ldbm_cache_close( be, db );
-       ber_bvfree( prefix );
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@@ -328,7 +330,7 @@ equality_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
+       struct berval prefix = {0};
        struct berval **keys = NULL;
        MatchingRule *mr;
 
@@ -369,18 +371,15 @@ equality_candidates(
                        0, 0, 0 );
 #endif
 
-               ber_bvfree( prefix );
                return idl;
        }
 
        mr = ava->aa_desc->ad_type->sat_equality;
        if( !mr ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
        if( !mr->smr_filter ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
@@ -389,12 +388,10 @@ equality_candidates(
                mask,
                ava->aa_desc->ad_type->sat_syntax,
                mr,
-               prefix,
+               &prefix,
                ava->aa_value,
                &keys );
 
-       ber_bvfree( prefix );
-
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@@ -512,7 +509,7 @@ approx_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
+       struct berval prefix = {0};
        struct berval **keys = NULL;
        MatchingRule *mr;
 
@@ -553,7 +550,6 @@ approx_candidates(
                        0, 0, 0 );
 #endif
 
-               ber_bvfree( prefix );
                return idl;
        }
 
@@ -564,12 +560,10 @@ approx_candidates(
        }
 
        if( !mr ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
        if( !mr->smr_filter ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
@@ -578,12 +572,10 @@ approx_candidates(
                mask,
                ava->aa_desc->ad_type->sat_syntax,
                mr,
-               prefix,
+               &prefix,
                ava->aa_value,
                &keys );
 
-       ber_bvfree( prefix );
-
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@@ -758,7 +750,7 @@ substring_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
+       struct berval prefix = {0};
        struct berval **keys = NULL;
        MatchingRule *mr;
 
@@ -799,19 +791,16 @@ substring_candidates(
                        0, 0, 0 );
 #endif
 
-               ber_bvfree( prefix );
                return idl;
        }
 
        mr = sub->sa_desc->ad_type->sat_substr;
 
        if( !mr ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
        if( !mr->smr_filter ) {
-               ber_bvfree( prefix );
                return idl;
        }
 
@@ -820,12 +809,10 @@ substring_candidates(
                mask,
                sub->sa_desc->ad_type->sat_syntax,
                mr,
-               prefix,
+               &prefix,
                sub,
                &keys );
 
-       ber_bvfree( prefix );
-
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_ERR,