]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/filterindex.c
Ditch LRU cache replacement in favor of 2nd-chance/clock.
[openldap] / servers / slapd / back-bdb / filterindex.c
index b6bc5328b0a0fce2e4011962969582c9b6803ca7..526224918cbc7781b0f0a7393ec847abb995396a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2005 The OpenLDAP Foundation.
+ * Copyright 2000-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -102,6 +102,11 @@ bdb_filter_candidates(
 #endif
        Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 );
 
+       if ( f->f_choice & SLAPD_FILTER_UNDEFINED ) {
+               BDB_IDL_ZERO( ids );
+               goto out;
+       }
+
        switch ( f->f_choice ) {
        case SLAPD_FILTER_COMPUTED:
                switch( f->f_result ) {
@@ -154,7 +159,7 @@ bdb_filter_candidates(
                /* if no GE index, use pres */
                Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
                if( f->f_ava->aa_desc->ad_type->sat_ordering &&
-                       ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) )
+                       ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) )
                        rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_GE );
                else
                        rc = presence_candidates( op, f->f_ava->aa_desc, ids );
@@ -164,7 +169,7 @@ bdb_filter_candidates(
                /* if no LE index, use pres */
                Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
                if( f->f_ava->aa_desc->ad_type->sat_ordering &&
-                       ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) )
+                       ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage & SLAP_MR_ORDERED_INDEX ) )
                        rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_LE );
                else
                        rc = presence_candidates( op, f->f_ava->aa_desc, ids );
@@ -204,6 +209,7 @@ bdb_filter_candidates(
                }
        }
 
+out:
        Debug( LDAP_DEBUG_FILTER,
                "<= bdb_filter_candidates: id=%ld first=%ld last=%ld\n",
                (long) ids[0],
@@ -305,8 +311,12 @@ comp_equality_candidates (
                return 0;
 
        ai = bdb_attr_mask( op->o_bd->be_private, mra->ma_desc );
-       if( ai )
+       if( ai ) {
                cr_list = ai->ai_cr;
+       }
+       else {
+               return 0;
+       }
        /* find a component reference to be indexed */
        sat_syntax = ca->ca_ma_rule->smr_syntax;
        for ( cr = cr_list ; cr ; cr = cr->cr_next ) {
@@ -974,7 +984,6 @@ inequality_candidates(
 {
        struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
        DB      *db;
-       int i;
        int rc;
        slap_mask_t mask;
        struct berval prefix = {0, NULL};
@@ -1062,9 +1071,11 @@ inequality_candidates(
 
                bdb_idl_union( ids, tmp );
 
-               if( BDB_IDL_IS_ZERO( ids ) )
+               if( op->ors_limit && op->ors_limit->lms_s_unchecked != -1 &&
+                       BDB_IDL_N( ids ) >= (unsigned) op->ors_limit->lms_s_unchecked ) {
+                       cursor->c_close( cursor );
                        break;
-               i++;
+               }
        }
        ber_bvarray_free_x( keys, op->o_tmpmemctx );