]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/filterindex.c
Remove abandon cruft
[openldap] / servers / slapd / back-ldbm / filterindex.c
index 8732599d74840b7ff0e3b693ef11492ac56a4144..9b5db4549291189ddd85d3449416734de4c75d41 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"));
@@ -95,7 +95,7 @@ filter_candidates(
                LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
                           "filter_candidates:  EQUALITY (%s),(%s)\n",
                           f->f_ava->aa_desc->ad_cname.bv_val,
-                          f->f_ava->aa_value->bv_val ));
+                          f->f_ava->aa_value.bv_val ));
 #else
                Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
 #endif
@@ -108,7 +108,7 @@ filter_candidates(
                LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
                           "filter_candidates:  APPROX (%s), (%s)\n",
                           f->f_ava->aa_desc->ad_cname.bv_val,
-                          f->f_ava->aa_value->bv_val ));
+                          f->f_ava->aa_value.bv_val ));
 #else
                Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
 #endif
@@ -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,8 +330,8 @@ equality_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
-       struct berval **keys = NULL;
+       struct berval prefix = {0};
+       struct berval *keys = NULL;
        MatchingRule *mr;
 
 #ifdef NEW_LOGGING
@@ -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,
-               ava->aa_value,
+               &prefix,
+               &ava->aa_value,
                &keys );
 
-       ber_bvfree( prefix );
-
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@@ -439,11 +436,11 @@ equality_candidates(
                return idl;
        }
 
-       for ( i= 0; keys[i] != NULL; i++ ) {
+       for ( i= 0; keys[i].bv_val != NULL; i++ ) {
                ID_BLOCK *save;
                ID_BLOCK *tmp;
 
-               rc = key_read( be, db, keys[i], &tmp );
+               rc = key_read( be, db, &keys[i], &tmp );
 
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
@@ -483,7 +480,7 @@ equality_candidates(
                if( idl == NULL ) break;
        }
 
-       ber_bvecfree( keys );
+       bvarray_free( keys );
 
        ldbm_cache_close( be, db );
 
@@ -512,8 +509,8 @@ approx_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
-       struct berval **keys = NULL;
+       struct berval prefix = {0};
+       struct berval *keys = NULL;
        MatchingRule *mr;
 
 #ifdef NEW_LOGGING
@@ -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,
-               ava->aa_value,
+               &prefix,
+               &ava->aa_value,
                &keys );
 
-       ber_bvfree( prefix );
-
        if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@@ -628,11 +620,11 @@ approx_candidates(
                return idl;
        }
 
-       for ( i= 0; keys[i] != NULL; i++ ) {
+       for ( i= 0; keys[i].bv_val != NULL; i++ ) {
                ID_BLOCK *save;
                ID_BLOCK *tmp;
 
-               rc = key_read( be, db, keys[i], &tmp );
+               rc = key_read( be, db, &keys[i], &tmp );
 
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
@@ -670,7 +662,7 @@ approx_candidates(
                if( idl == NULL ) break;
        }
 
-       ber_bvecfree( keys );
+       bvarray_free( keys );
 
        ldbm_cache_close( be, db );
 
@@ -758,8 +750,8 @@ substring_candidates(
        int rc;
        char *dbname;
        slap_mask_t mask;
-       struct berval *prefix;
-       struct berval **keys = NULL;
+       struct berval prefix = {0};
+       struct berval *keys = NULL;
        MatchingRule *mr;
 
 #ifdef NEW_LOGGING
@@ -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,
@@ -870,11 +857,11 @@ substring_candidates(
                return idl;
        }
 
-       for ( i= 0; keys[i] != NULL; i++ ) {
+       for ( i= 0; keys[i].bv_val != NULL; i++ ) {
                ID_BLOCK *save;
                ID_BLOCK *tmp;
 
-               rc = key_read( be, db, keys[i], &tmp );
+               rc = key_read( be, db, &keys[i], &tmp );
 
                if( rc != LDAP_SUCCESS ) {
                        idl_free( idl );
@@ -913,7 +900,7 @@ substring_candidates(
                if( idl == NULL ) break;
        }
 
-       ber_bvecfree( keys );
+       bvarray_free( keys );
 
        ldbm_cache_close( be, db );