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-2005 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
424 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
425 BDB_IDL_ALL( bdb, ids );
429 return comp_candidates ( op, mra, mra->ma_cf, ids, tmp, stack);
442 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
446 Debug( LDAP_DEBUG_FILTER, "=> bdb_list_candidates 0x%x\n", ftype, 0, 0 );
447 for ( f = flist; f != NULL; f = f->f_next ) {
448 /* ignore precomputed scopes */
449 if ( f->f_choice == SLAPD_FILTER_COMPUTED &&
450 f->f_result == LDAP_SUCCESS ) {
453 BDB_IDL_ZERO( save );
454 rc = bdb_filter_candidates( op, f, save, tmp,
455 save+BDB_IDL_UM_SIZE );
458 if ( ftype == LDAP_FILTER_AND ) {
466 if ( ftype == LDAP_FILTER_AND ) {
468 BDB_IDL_CPY( ids, save );
470 bdb_idl_intersection( ids, save );
472 if( BDB_IDL_IS_ZERO( ids ) )
476 BDB_IDL_CPY( ids, save );
478 bdb_idl_union( ids, save );
483 if( rc == LDAP_SUCCESS ) {
484 Debug( LDAP_DEBUG_FILTER,
485 "<= bdb_list_candidates: id=%ld first=%ld last=%ld\n",
487 (long) BDB_IDL_FIRST(ids),
488 (long) BDB_IDL_LAST(ids) );
491 Debug( LDAP_DEBUG_FILTER,
492 "<= bdb_list_candidates: undefined rc=%d\n",
502 AttributeDescription *desc,
505 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
509 struct berval prefix = {0, NULL};
511 Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates (%s)\n",
512 desc->ad_cname.bv_val, 0, 0 );
514 BDB_IDL_ALL( bdb, ids );
516 if( desc == slap_schema.si_ad_objectClass ) {
520 rc = bdb_index_param( op->o_bd, desc, LDAP_FILTER_PRESENT,
521 &db, &mask, &prefix );
523 if( rc != LDAP_SUCCESS ) {
524 Debug( LDAP_DEBUG_TRACE,
525 "<= bdb_presence_candidates: (%s) index_param "
527 desc->ad_cname.bv_val, rc, 0 );
533 Debug( LDAP_DEBUG_TRACE,
534 "<= bdb_presence_candidates: (%s) not indexed\n",
535 desc->ad_cname.bv_val, 0, 0 );
539 if( prefix.bv_val == NULL ) {
540 Debug( LDAP_DEBUG_TRACE,
541 "<= bdb_presence_candidates: (%s) no prefix\n",
542 desc->ad_cname.bv_val, 0, 0 );
546 rc = bdb_key_read( op->o_bd, db, NULL, &prefix, ids, NULL, 0 );
548 if( rc == DB_NOTFOUND ) {
551 } else if( rc != LDAP_SUCCESS ) {
552 Debug( LDAP_DEBUG_TRACE,
553 "<= bdb_presense_candidates: (%s) "
554 "key read failed (%d)\n",
555 desc->ad_cname.bv_val, rc, 0 );
559 Debug(LDAP_DEBUG_TRACE,
560 "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n",
562 (long) BDB_IDL_FIRST(ids),
563 (long) BDB_IDL_LAST(ids) );
572 AttributeAssertion *ava,
576 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
581 struct berval prefix = {0, NULL};
582 struct berval *keys = NULL;
585 Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates (%s)\n",
586 ava->aa_desc->ad_cname.bv_val, 0, 0 );
588 BDB_IDL_ALL( bdb, ids );
590 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY,
591 &db, &mask, &prefix );
593 if( rc != LDAP_SUCCESS ) {
594 Debug( LDAP_DEBUG_ANY,
595 "<= bdb_equality_candidates: (%s) "
596 "index_param failed (%d)\n",
597 ava->aa_desc->ad_cname.bv_val, rc, 0 );
602 Debug( LDAP_DEBUG_ANY,
603 "<= bdb_equality_candidates: (%s) not indexed\n",
604 ava->aa_desc->ad_cname.bv_val, 0, 0 );
608 mr = ava->aa_desc->ad_type->sat_equality;
613 if( !mr->smr_filter ) {
617 rc = (mr->smr_filter)(
618 LDAP_FILTER_EQUALITY,
620 ava->aa_desc->ad_type->sat_syntax,
624 &keys, op->o_tmpmemctx );
626 if( rc != LDAP_SUCCESS ) {
627 Debug( LDAP_DEBUG_TRACE,
628 "<= bdb_equality_candidates: (%s, %s) "
629 "MR filter failed (%d)\n",
630 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
635 Debug( LDAP_DEBUG_TRACE,
636 "<= bdb_equality_candidates: (%s) no keys\n",
637 ava->aa_desc->ad_cname.bv_val, 0, 0 );
641 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
642 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
644 if( rc == DB_NOTFOUND ) {
648 } else if( rc != LDAP_SUCCESS ) {
649 Debug( LDAP_DEBUG_TRACE,
650 "<= bdb_equality_candidates: (%s) "
651 "key read failed (%d)\n",
652 ava->aa_desc->ad_cname.bv_val, rc, 0 );
656 if( BDB_IDL_IS_ZERO( tmp ) ) {
657 Debug( LDAP_DEBUG_TRACE,
658 "<= bdb_equality_candidates: (%s) NULL\n",
659 ava->aa_desc->ad_cname.bv_val, 0, 0 );
665 BDB_IDL_CPY( ids, tmp );
667 bdb_idl_intersection( ids, tmp );
670 if( BDB_IDL_IS_ZERO( ids ) )
674 ber_bvarray_free_x( keys, op->o_tmpmemctx );
676 Debug( LDAP_DEBUG_TRACE,
677 "<= bdb_equality_candidates: id=%ld, first=%ld, last=%ld\n",
679 (long) BDB_IDL_FIRST(ids),
680 (long) BDB_IDL_LAST(ids) );
688 AttributeAssertion *ava,
692 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
697 struct berval prefix = {0, NULL};
698 struct berval *keys = NULL;
701 Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates (%s)\n",
702 ava->aa_desc->ad_cname.bv_val, 0, 0 );
704 BDB_IDL_ALL( bdb, ids );
706 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_APPROX,
707 &db, &mask, &prefix );
709 if( rc != LDAP_SUCCESS ) {
710 Debug( LDAP_DEBUG_ANY,
711 "<= bdb_approx_candidates: (%s) "
712 "index_param failed (%d)\n",
713 ava->aa_desc->ad_cname.bv_val, rc, 0 );
718 Debug( LDAP_DEBUG_ANY,
719 "<= bdb_approx_candidates: (%s) not indexed\n",
720 ava->aa_desc->ad_cname.bv_val, 0, 0 );
724 mr = ava->aa_desc->ad_type->sat_approx;
726 /* no approx matching rule, try equality matching rule */
727 mr = ava->aa_desc->ad_type->sat_equality;
734 if( !mr->smr_filter ) {
738 rc = (mr->smr_filter)(
741 ava->aa_desc->ad_type->sat_syntax,
745 &keys, op->o_tmpmemctx );
747 if( rc != LDAP_SUCCESS ) {
748 Debug( LDAP_DEBUG_TRACE,
749 "<= bdb_approx_candidates: (%s, %s) "
750 "MR filter failed (%d)\n",
751 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
756 Debug( LDAP_DEBUG_TRACE,
757 "<= bdb_approx_candidates: (%s) no keys (%s)\n",
758 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, 0 );
762 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
763 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
765 if( rc == DB_NOTFOUND ) {
769 } else if( rc != LDAP_SUCCESS ) {
770 Debug( LDAP_DEBUG_TRACE,
771 "<= bdb_approx_candidates: (%s) "
772 "key read failed (%d)\n",
773 ava->aa_desc->ad_cname.bv_val, rc, 0 );
777 if( BDB_IDL_IS_ZERO( tmp ) ) {
778 Debug( LDAP_DEBUG_TRACE,
779 "<= bdb_approx_candidates: (%s) NULL\n",
780 ava->aa_desc->ad_cname.bv_val, 0, 0 );
786 BDB_IDL_CPY( ids, tmp );
788 bdb_idl_intersection( ids, tmp );
791 if( BDB_IDL_IS_ZERO( ids ) )
795 ber_bvarray_free_x( keys, op->o_tmpmemctx );
797 Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n",
799 (long) BDB_IDL_FIRST(ids),
800 (long) BDB_IDL_LAST(ids) );
805 substring_candidates(
807 SubstringsAssertion *sub,
811 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
816 struct berval prefix = {0, NULL};
817 struct berval *keys = NULL;
820 Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates (%s)\n",
821 sub->sa_desc->ad_cname.bv_val, 0, 0 );
823 BDB_IDL_ALL( bdb, ids );
825 rc = bdb_index_param( op->o_bd, sub->sa_desc, LDAP_FILTER_SUBSTRINGS,
826 &db, &mask, &prefix );
828 if( rc != LDAP_SUCCESS ) {
829 Debug( LDAP_DEBUG_ANY,
830 "<= bdb_substring_candidates: (%s) "
831 "index_param failed (%d)\n",
832 sub->sa_desc->ad_cname.bv_val, rc, 0 );
837 Debug( LDAP_DEBUG_ANY,
838 "<= bdb_substring_candidates: (%s) not indexed\n",
839 sub->sa_desc->ad_cname.bv_val, 0, 0 );
843 mr = sub->sa_desc->ad_type->sat_substr;
849 if( !mr->smr_filter ) {
853 rc = (mr->smr_filter)(
854 LDAP_FILTER_SUBSTRINGS,
856 sub->sa_desc->ad_type->sat_syntax,
860 &keys, op->o_tmpmemctx );
862 if( rc != LDAP_SUCCESS ) {
863 Debug( LDAP_DEBUG_TRACE,
864 "<= bdb_substring_candidates: (%s) "
865 "MR filter failed (%d)\n",
866 sub->sa_desc->ad_cname.bv_val, rc, 0 );
871 Debug( LDAP_DEBUG_TRACE,
872 "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n",
873 mask, sub->sa_desc->ad_cname.bv_val, 0 );
877 for ( i= 0; keys[i].bv_val != NULL; i++ ) {
878 rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 );
880 if( rc == DB_NOTFOUND ) {
884 } else if( rc != LDAP_SUCCESS ) {
885 Debug( LDAP_DEBUG_TRACE,
886 "<= bdb_substring_candidates: (%s) "
887 "key read failed (%d)\n",
888 sub->sa_desc->ad_cname.bv_val, rc, 0 );
892 if( BDB_IDL_IS_ZERO( tmp ) ) {
893 Debug( LDAP_DEBUG_TRACE,
894 "<= bdb_substring_candidates: (%s) NULL\n",
895 sub->sa_desc->ad_cname.bv_val, 0, 0 );
901 BDB_IDL_CPY( ids, tmp );
903 bdb_idl_intersection( ids, tmp );
906 if( BDB_IDL_IS_ZERO( ids ) )
910 ber_bvarray_free_x( keys, op->o_tmpmemctx );
912 Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: %ld, first=%ld, last=%ld\n",
914 (long) BDB_IDL_FIRST(ids),
915 (long) BDB_IDL_LAST(ids) );
920 inequality_candidates(
922 AttributeAssertion *ava,
927 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
932 struct berval prefix = {0, NULL};
933 struct berval *keys = NULL;
937 Debug( LDAP_DEBUG_TRACE, "=> bdb_inequality_candidates (%s)\n",
938 ava->aa_desc->ad_cname.bv_val, 0, 0 );
940 BDB_IDL_ALL( bdb, ids );
942 rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY,
943 &db, &mask, &prefix );
945 if( rc != LDAP_SUCCESS ) {
946 Debug( LDAP_DEBUG_ANY,
947 "<= bdb_inequality_candidates: (%s) "
948 "index_param failed (%d)\n",
949 ava->aa_desc->ad_cname.bv_val, rc, 0 );
954 Debug( LDAP_DEBUG_ANY,
955 "<= bdb_inequality_candidates: (%s) not indexed\n",
956 ava->aa_desc->ad_cname.bv_val, 0, 0 );
960 mr = ava->aa_desc->ad_type->sat_equality;
965 if( !mr->smr_filter ) {
969 rc = (mr->smr_filter)(
970 LDAP_FILTER_EQUALITY,
972 ava->aa_desc->ad_type->sat_syntax,
976 &keys, op->o_tmpmemctx );
978 if( rc != LDAP_SUCCESS ) {
979 Debug( LDAP_DEBUG_TRACE,
980 "<= bdb_inequality_candidates: (%s, %s) "
981 "MR filter failed (%d)\n",
982 prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc );
987 Debug( LDAP_DEBUG_TRACE,
988 "<= bdb_inequality_candidates: (%s) no keys\n",
989 ava->aa_desc->ad_cname.bv_val, 0, 0 );
995 rc = bdb_key_read( op->o_bd, db, NULL, &keys[0], tmp, &cursor, gtorlt );
997 if( rc == DB_NOTFOUND ) {
1000 } else if( rc != LDAP_SUCCESS ) {
1001 Debug( LDAP_DEBUG_TRACE,
1002 "<= bdb_inequality_candidates: (%s) "
1003 "key read failed (%d)\n",
1004 ava->aa_desc->ad_cname.bv_val, rc, 0 );
1008 if( BDB_IDL_IS_ZERO( tmp ) ) {
1009 Debug( LDAP_DEBUG_TRACE,
1010 "<= bdb_inequality_candidates: (%s) NULL\n",
1011 ava->aa_desc->ad_cname.bv_val, 0, 0 );
1015 bdb_idl_union( ids, tmp );
1017 if( BDB_IDL_IS_ZERO( ids ) )
1021 ber_bvarray_free_x( keys, op->o_tmpmemctx );
1023 Debug( LDAP_DEBUG_TRACE,
1024 "<= bdb_inequality_candidates: id=%ld, first=%ld, last=%ld\n",
1026 (long) BDB_IDL_FIRST(ids),
1027 (long) BDB_IDL_LAST(ids) );