1 /* filterindex.c - generate the list of candidate entries from a filter */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
25 static int presence_candidates(
27 AttributeDescription *desc,
30 static int equality_candidates(
32 AttributeAssertion *ava,
35 static int inequality_candidates(
37 AttributeAssertion *ava,
41 static int approx_candidates(
43 AttributeAssertion *ava,
46 static int substring_candidates(
48 SubstringsAssertion *sub,
52 static int list_candidates(
60 #ifdef LDAP_COMP_MATCH
64 MatchingRuleAssertion *mra,
72 MatchingRuleAssertion *mra,
80 bdb_filter_candidates(
88 Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 );
90 switch ( f->f_choice ) {
91 case SLAPD_FILTER_COMPUTED:
92 switch( f->f_result ) {
93 case SLAPD_COMPARE_UNDEFINED:
94 /* This technically is not the same as FALSE, but it
95 * certainly will produce no matches.
98 case LDAP_COMPARE_FALSE:
101 case LDAP_COMPARE_TRUE: {
102 struct bdb_info *bdb = (struct bdb_info *)op->o_bd->be_private;
103 BDB_IDL_ALL( bdb, ids );
106 /* this is a pre-computed scope, leave it alone */
110 case LDAP_FILTER_PRESENT:
111 Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 );
112 rc = presence_candidates( op, f->f_desc, ids );
115 case LDAP_FILTER_EQUALITY:
116 Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
117 rc = equality_candidates( op, f->f_ava, ids, tmp );
120 case LDAP_FILTER_APPROX:
121 Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
122 rc = approx_candidates( op, f->f_ava, ids, tmp );
125 case LDAP_FILTER_SUBSTRINGS:
126 Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 );
127 rc = substring_candidates( op, f->f_sub, ids, tmp );
131 /* if no GE index, use pres */
132 Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
133 if( f->f_ava->aa_desc->ad_type->sat_ordering &&
134 ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) )
135 rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_GE );
137 rc = presence_candidates( op, f->f_ava->aa_desc, ids );
141 /* if no LE index, use pres */
142 Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
143 if( f->f_ava->aa_desc->ad_type->sat_ordering &&
144 ( f->f_ava->aa_desc->ad_type->sat_ordering->smr_usage && SLAP_MR_ORDERED_INDEX ) )
145 rc = inequality_candidates( op, f->f_ava, ids, tmp, LDAP_FILTER_LE );
147 rc = presence_candidates( op, f->f_ava->aa_desc, ids );
150 case LDAP_FILTER_NOT:
151 /* no indexing to support NOT filters */
152 Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 );
153 { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
154 BDB_IDL_ALL( bdb, ids );
158 case LDAP_FILTER_AND:
159 Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 );
160 rc = list_candidates( op,
161 f->f_and, LDAP_FILTER_AND, ids, tmp, stack );
165 Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 );
166 rc = list_candidates( op,
167 f->f_or, LDAP_FILTER_OR, ids, tmp, stack );
169 #ifdef LDAP_COMP_MATCH
170 case LDAP_FILTER_EXT:
171 Debug( LDAP_DEBUG_FILTER, "\tEXT\n", 0, 0, 0 );
172 rc = ext_candidates( op, f->f_mra, ids, tmp, stack );
176 Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n",
177 (unsigned long) f->f_choice, 0, 0 );
178 /* Must not return NULL, otherwise extended filters break */
179 { struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
180 BDB_IDL_ALL( bdb, ids );
184 Debug( LDAP_DEBUG_FILTER,
185 "<= bdb_filter_candidates: id=%ld first=%ld last=%ld\n",
187 (long) BDB_IDL_FIRST( ids ),
188 (long) BDB_IDL_LAST( ids ) );
193 #ifdef LDAP_COMP_MATCH
195 comp_list_candidates(
197 MatchingRuleAssertion* mra,
198 ComponentFilter *flist,
204 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
208 Debug( LDAP_DEBUG_FILTER, "=> comp_list_candidates 0x%x\n", ftype, 0, 0 );
209 for ( f = flist; f != NULL; f = f->cf_next ) {
210 /* ignore precomputed scopes */
211 if ( f->cf_choice == SLAPD_FILTER_COMPUTED &&
212 f->cf_result == LDAP_SUCCESS ) {
215 BDB_IDL_ZERO( save );
216 rc = comp_candidates( op, mra, f, save, tmp, save+BDB_IDL_UM_SIZE );
219 if ( ftype == LDAP_COMP_FILTER_AND ) {
226 if ( ftype == LDAP_COMP_FILTER_AND ) {
228 BDB_IDL_CPY( ids, save );
230 bdb_idl_intersection( ids, save );
232 if( BDB_IDL_IS_ZERO( ids ) )
236 BDB_IDL_CPY( ids, save );
238 bdb_idl_union( ids, save );
243 if( rc == LDAP_SUCCESS ) {
244 Debug( LDAP_DEBUG_FILTER,
245 "<= comp_list_candidates: id=%ld first=%ld last=%ld\n",
247 (long) BDB_IDL_FIRST(ids),
248 (long) BDB_IDL_LAST(ids) );
251 Debug( LDAP_DEBUG_FILTER,
252 "<= comp_list_candidates: undefined rc=%d\n",
260 comp_equality_candidates (
262 MatchingRuleAssertion *mra,
263 ComponentAssertion *ca,
268 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
273 struct berval prefix = {0, NULL};
274 struct berval *keys = NULL;
275 MatchingRule *mr = mra->ma_rule;
277 ComponentReference* cr_list, *cr;
279 BDB_IDL_ALL( bdb, ids );
281 bdb_attr_comp_ref ( op->o_bd->be_private, mra->ma_desc, &cr_list );
282 if( !cr_list || !ca->ca_comp_ref )
284 /* find a component reference to be indexed */
285 sat_syntax = ca->ca_ma_rule->smr_syntax;
286 for ( cr = cr_list ; cr ; cr = cr->cr_next ) {
287 if ( cr->cr_string.bv_len == ca->ca_comp_ref->cr_string.bv_len &&
288 strncmp( cr->cr_string.bv_val, ca->ca_comp_ref->cr_string.bv_val,cr->cr_string.bv_len ) == 0 )
295 rc = bdb_index_param( op->o_bd, mra->ma_desc, LDAP_FILTER_EQUALITY,
296 &db, &mask, &prefix );
298 if( rc != LDAP_SUCCESS ) {
309 if( !mr->smr_filter ) {
313 rc = (ca->ca_ma_rule->smr_filter)(
314 LDAP_FILTER_EQUALITY,
320 &keys, op->o_tmpmemctx );
322 if( rc != LDAP_SUCCESS ) {
329 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
330 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
332 if( rc == DB_NOTFOUND ) {
336 } else if( rc != LDAP_SUCCESS ) {
340 if( BDB_IDL_IS_ZERO( tmp ) ) {
346 BDB_IDL_CPY( ids, tmp );
348 bdb_idl_intersection( ids, tmp );
351 if( BDB_IDL_IS_ZERO( ids ) )
354 ber_bvarray_free_x( keys, op->o_tmpmemctx );
356 Debug( LDAP_DEBUG_TRACE,
357 "<= comp_equality_candidates: id=%ld, first=%ld, last=%ld\n",
359 (long) BDB_IDL_FIRST(ids),
360 (long) BDB_IDL_LAST(ids) );
367 MatchingRuleAssertion *mra,
375 if ( !f ) return LDAP_PROTOCOL_ERROR;
377 Debug( LDAP_DEBUG_FILTER, "comp_candidates\n", 0, 0, 0 );
378 switch ( f->cf_choice ) {
379 case SLAPD_FILTER_COMPUTED:
382 case LDAP_COMP_FILTER_AND:
383 rc = comp_list_candidates( op, mra, f->cf_and, LDAP_COMP_FILTER_AND, ids, tmp, stack );
385 case LDAP_COMP_FILTER_OR:
386 rc = comp_list_candidates( op, mra, f->cf_or, LDAP_COMP_FILTER_OR, ids, tmp, stack );
388 case LDAP_COMP_FILTER_NOT:
389 /* No component indexing supported for NOT filter */
390 Debug( LDAP_DEBUG_FILTER, "\tComponent NOT\n", 0, 0, 0 );
392 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
393 BDB_IDL_ALL( bdb, ids );
395 rc = LDAP_PROTOCOL_ERROR;
397 case LDAP_COMP_FILTER_ITEM:
398 rc = comp_equality_candidates( op, mra, f->cf_ca, ids, tmp, stack );
402 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
403 BDB_IDL_ALL( bdb, ids );
405 rc = LDAP_PROTOCOL_ERROR;
414 MatchingRuleAssertion *mra,
420 * Currently Only Component Indexing for componentFilterMatch is supported
421 * Indexing for an extensible filter is not supported yet
425 return comp_candidates ( op, mra, mra->ma_cf, ids, tmp, stack);
438 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
442 Debug( LDAP_DEBUG_FILTER, "=> bdb_list_candidates 0x%x\n", ftype, 0, 0 );
443 for ( f = flist; f != NULL; f = f->f_next ) {
444 /* ignore precomputed scopes */
445 if ( f->f_choice == SLAPD_FILTER_COMPUTED &&
446 f->f_result == LDAP_SUCCESS ) {
449 BDB_IDL_ZERO( save );
450 rc = bdb_filter_candidates( op, f, save, tmp,
451 save+BDB_IDL_UM_SIZE );
454 if ( ftype == LDAP_FILTER_AND ) {
462 if ( ftype == LDAP_FILTER_AND ) {
464 BDB_IDL_CPY( ids, save );
466 bdb_idl_intersection( ids, save );
468 if( BDB_IDL_IS_ZERO( ids ) )
472 BDB_IDL_CPY( ids, save );
474 bdb_idl_union( ids, save );
479 if( rc == LDAP_SUCCESS ) {
480 Debug( LDAP_DEBUG_FILTER,
481 "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n",
483 (long) BDB_IDL_FIRST(ids),
484 (long) BDB_IDL_LAST(ids) );
487 Debug( LDAP_DEBUG_FILTER,
488 "<= bdb_list_candidates: undefined rc=%d\n",
498 AttributeDescription *desc,
501 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
505 struct berval prefix = {0, NULL};
507 Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates (%s)\n",
508 desc->ad_cname.bv_val, 0, 0 );
510 BDB_IDL_ALL( bdb, ids );
512 if( desc == slap_schema.si_ad_objectClass ) {
516 rc = bdb_index_param( op->o_bd, desc, LDAP_FILTER_PRESENT,
517 &db, &mask, &prefix );
519 if( rc != LDAP_SUCCESS ) {
520 Debug( LDAP_DEBUG_TRACE,
521 "<= bdb_presence_candidates: (%s) index_param "
523 desc->ad_cname.bv_val, rc, 0 );
529 Debug( LDAP_DEBUG_TRACE,
530 "<= bdb_presence_candidates: (%s) not indexed\n",
531 desc->ad_cname.bv_val, 0, 0 );
535 if( prefix.bv_val == NULL ) {
536 Debug( LDAP_DEBUG_TRACE,
537 "<= bdb_presence_candidates: (%s) no prefix\n",
538 desc->ad_cname.bv_val, 0, 0 );
542 rc = bdb_key_read( op->o_bd, db, NULL, &prefix, ids, NULL, 0 );
544 if( rc == DB_NOTFOUND ) {
547 } else if( rc != LDAP_SUCCESS ) {
548 Debug( LDAP_DEBUG_TRACE,
549 "<= bdb_presense_candidates: (%s) "
550 "key read failed (%d)\n",
551 desc->ad_cname.bv_val, rc, 0 );
555 Debug(LDAP_DEBUG_TRACE,
556 "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n",
558 (long) BDB_IDL_FIRST(ids),
559 (long) BDB_IDL_LAST(ids) );
568 AttributeAssertion *ava,
572 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
577 struct berval prefix = {0, NULL};
578 struct berval *keys = NULL;
581 Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates (%s)\n",
582 ava->aa_desc->ad_cname.bv_val, 0, 0 );
584 BDB_IDL_ALL( bdb, ids );
586 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY,
587 &db, &mask, &prefix );
589 if( rc != LDAP_SUCCESS ) {
590 Debug( LDAP_DEBUG_ANY,
591 "<= bdb_equality_candidates: (%s) "
592 "index_param failed (%d)\n",
593 ava->aa_desc->ad_cname.bv_val, rc, 0 );
598 Debug( LDAP_DEBUG_ANY,
599 "<= bdb_equality_candidates: (%s) not indexed\n",
600 ava->aa_desc->ad_cname.bv_val, 0, 0 );
604 mr = ava->aa_desc->ad_type->sat_equality;
609 if( !mr->smr_filter ) {
613 rc = (mr->smr_filter)(
614 LDAP_FILTER_EQUALITY,
616 ava->aa_desc->ad_type->sat_syntax,
620 &keys, op->o_tmpmemctx );
622 if( rc != LDAP_SUCCESS ) {
623 Debug( LDAP_DEBUG_TRACE,
624 "<= bdb_equality_candidates: (%s, %s) "
625 "MR filter failed (%d)\n",
626 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
631 Debug( LDAP_DEBUG_TRACE,
632 "<= bdb_equality_candidates: (%s) no keys\n",
633 ava->aa_desc->ad_cname.bv_val, 0, 0 );
637 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
638 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
640 if( rc == DB_NOTFOUND ) {
644 } else if( rc != LDAP_SUCCESS ) {
645 Debug( LDAP_DEBUG_TRACE,
646 "<= bdb_equality_candidates: (%s) "
647 "key read failed (%d)\n",
648 ava->aa_desc->ad_cname.bv_val, rc, 0 );
652 if( BDB_IDL_IS_ZERO( tmp ) ) {
653 Debug( LDAP_DEBUG_TRACE,
654 "<= bdb_equality_candidates: (%s) NULL\n",
655 ava->aa_desc->ad_cname.bv_val, 0, 0 );
661 BDB_IDL_CPY( ids, tmp );
663 bdb_idl_intersection( ids, tmp );
666 if( BDB_IDL_IS_ZERO( ids ) )
670 ber_bvarray_free_x( keys, op->o_tmpmemctx );
672 Debug( LDAP_DEBUG_TRACE,
673 "<= bdb_equality_candidates: id=%ld, first=%ld, last=%ld\n",
675 (long) BDB_IDL_FIRST(ids),
676 (long) BDB_IDL_LAST(ids) );
684 AttributeAssertion *ava,
688 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
693 struct berval prefix = {0, NULL};
694 struct berval *keys = NULL;
697 Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates (%s)\n",
698 ava->aa_desc->ad_cname.bv_val, 0, 0 );
700 BDB_IDL_ALL( bdb, ids );
702 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_APPROX,
703 &db, &mask, &prefix );
705 if( rc != LDAP_SUCCESS ) {
706 Debug( LDAP_DEBUG_ANY,
707 "<= bdb_approx_candidates: (%s) "
708 "index_param failed (%d)\n",
709 ava->aa_desc->ad_cname.bv_val, rc, 0 );
714 Debug( LDAP_DEBUG_ANY,
715 "<= bdb_approx_candidates: (%s) not indexed\n",
716 ava->aa_desc->ad_cname.bv_val, 0, 0 );
720 mr = ava->aa_desc->ad_type->sat_approx;
722 /* no approx matching rule, try equality matching rule */
723 mr = ava->aa_desc->ad_type->sat_equality;
730 if( !mr->smr_filter ) {
734 rc = (mr->smr_filter)(
737 ava->aa_desc->ad_type->sat_syntax,
741 &keys, op->o_tmpmemctx );
743 if( rc != LDAP_SUCCESS ) {
744 Debug( LDAP_DEBUG_TRACE,
745 "<= bdb_approx_candidates: (%s, %s) "
746 "MR filter failed (%d)\n",
747 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
752 Debug( LDAP_DEBUG_TRACE,
753 "<= bdb_approx_candidates: (%s) no keys (%s)\n",
754 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, 0 );
758 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
759 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
761 if( rc == DB_NOTFOUND ) {
765 } else if( rc != LDAP_SUCCESS ) {
766 Debug( LDAP_DEBUG_TRACE,
767 "<= bdb_approx_candidates: (%s) "
768 "key read failed (%d)\n",
769 ava->aa_desc->ad_cname.bv_val, rc, 0 );
773 if( BDB_IDL_IS_ZERO( tmp ) ) {
774 Debug( LDAP_DEBUG_TRACE,
775 "<= bdb_approx_candidates: (%s) NULL\n",
776 ava->aa_desc->ad_cname.bv_val, 0, 0 );
782 BDB_IDL_CPY( ids, tmp );
784 bdb_idl_intersection( ids, tmp );
787 if( BDB_IDL_IS_ZERO( ids ) )
791 ber_bvarray_free_x( keys, op->o_tmpmemctx );
793 Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n",
795 (long) BDB_IDL_FIRST(ids),
796 (long) BDB_IDL_LAST(ids) );
801 substring_candidates(
803 SubstringsAssertion *sub,
807 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
812 struct berval prefix = {0, NULL};
813 struct berval *keys = NULL;
816 Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates (%s)\n",
817 sub->sa_desc->ad_cname.bv_val, 0, 0 );
819 BDB_IDL_ALL( bdb, ids );
821 rc = bdb_index_param( op->o_bd, sub->sa_desc, LDAP_FILTER_SUBSTRINGS,
822 &db, &mask, &prefix );
824 if( rc != LDAP_SUCCESS ) {
825 Debug( LDAP_DEBUG_ANY,
826 "<= bdb_substring_candidates: (%s) "
827 "index_param failed (%d)\n",
828 sub->sa_desc->ad_cname.bv_val, rc, 0 );
833 Debug( LDAP_DEBUG_ANY,
834 "<= bdb_substring_candidates: (%s) not indexed\n",
835 sub->sa_desc->ad_cname.bv_val, 0, 0 );
839 mr = sub->sa_desc->ad_type->sat_substr;
845 if( !mr->smr_filter ) {
849 rc = (mr->smr_filter)(
850 LDAP_FILTER_SUBSTRINGS,
852 sub->sa_desc->ad_type->sat_syntax,
856 &keys, op->o_tmpmemctx );
858 if( rc != LDAP_SUCCESS ) {
859 Debug( LDAP_DEBUG_TRACE,
860 "<= bdb_substring_candidates: (%s) "
861 "MR filter failed (%d)\n",
862 sub->sa_desc->ad_cname.bv_val, rc, 0 );
867 Debug( LDAP_DEBUG_TRACE,
868 "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n",
869 mask, sub->sa_desc->ad_cname.bv_val, 0 );
873 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
874 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
876 if( rc == DB_NOTFOUND ) {
880 } else if( rc != LDAP_SUCCESS ) {
881 Debug( LDAP_DEBUG_TRACE,
882 "<= bdb_substring_candidates: (%s) "
883 "key read failed (%d)\n",
884 sub->sa_desc->ad_cname.bv_val, rc, 0 );
888 if( BDB_IDL_IS_ZERO( tmp ) ) {
889 Debug( LDAP_DEBUG_TRACE,
890 "<= bdb_substring_candidates: (%s) NULL\n",
891 sub->sa_desc->ad_cname.bv_val, 0, 0 );
897 BDB_IDL_CPY( ids, tmp );
899 bdb_idl_intersection( ids, tmp );
902 if( BDB_IDL_IS_ZERO( ids ) )
906 ber_bvarray_free_x( keys, op->o_tmpmemctx );
908 Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: %ld, first=%ld, last=%ld\n",
910 (long) BDB_IDL_FIRST(ids),
911 (long) BDB_IDL_LAST(ids) );
916 inequality_candidates(
918 AttributeAssertion *ava,
923 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
928 struct berval prefix = {0, NULL};
929 struct berval *keys = NULL;
933 Debug( LDAP_DEBUG_TRACE, "=> bdb_inequality_candidates (%s)\n",
934 ava->aa_desc->ad_cname.bv_val, 0, 0 );
936 BDB_IDL_ALL( bdb, ids );
938 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY,
939 &db, &mask, &prefix );
941 if( rc != LDAP_SUCCESS ) {
942 Debug( LDAP_DEBUG_ANY,
943 "<= bdb_inequality_candidates: (%s) "
944 "index_param failed (%d)\n",
945 ava->aa_desc->ad_cname.bv_val, rc, 0 );
950 Debug( LDAP_DEBUG_ANY,
951 "<= bdb_inequality_candidates: (%s) not indexed\n",
952 ava->aa_desc->ad_cname.bv_val, 0, 0 );
956 mr = ava->aa_desc->ad_type->sat_equality;
961 if( !mr->smr_filter ) {
965 rc = (mr->smr_filter)(
966 LDAP_FILTER_EQUALITY,
968 ava->aa_desc->ad_type->sat_syntax,
972 &keys, op->o_tmpmemctx );
974 if( rc != LDAP_SUCCESS ) {
975 Debug( LDAP_DEBUG_TRACE,
976 "<= bdb_inequality_candidates: (%s, %s) "
977 "MR filter failed (%d)\n",
978 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
983 Debug( LDAP_DEBUG_TRACE,
984 "<= bdb_inequality_candidates: (%s) no keys\n",
985 ava->aa_desc->ad_cname.bv_val, 0, 0 );
991 rc = bdb_key_read( op->o_bd, db, NULL, &keys[0], tmp, &cursor, gtorlt );
993 if( rc == DB_NOTFOUND ) {
996 } else if( rc != LDAP_SUCCESS ) {
997 Debug( LDAP_DEBUG_TRACE,
998 "<= bdb_inequality_candidates: (%s) "
999 "key read failed (%d)\n",
1000 ava->aa_desc->ad_cname.bv_val, rc, 0 );
1004 if( BDB_IDL_IS_ZERO( tmp ) ) {
1005 Debug( LDAP_DEBUG_TRACE,
1006 "<= bdb_inequality_candidates: (%s) NULL\n",
1007 ava->aa_desc->ad_cname.bv_val, 0, 0 );
1011 bdb_idl_union( ids, tmp );
1013 if( BDB_IDL_IS_ZERO( ids ) )
1017 ber_bvarray_free_x( keys, op->o_tmpmemctx );
1019 Debug( LDAP_DEBUG_TRACE,
1020 "<= bdb_inequality_candidates: id=%ld, first=%ld, last=%ld\n",
1022 (long) BDB_IDL_FIRST(ids),
1023 (long) BDB_IDL_LAST(ids) );