📄 filterindex.c
字号:
Debug( LDAP_DEBUG_FILTER, "<= bdb_list_candidates: undefined rc=%d\n", rc, 0, 0 ); } return rc;}static intpresence_candidates( Operation *op, AttributeDescription *desc, ID *ids ){ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; DB *db; int rc; slap_mask_t mask; struct berval prefix = {0, NULL}; Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates (%s)\n", desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ALL( bdb, ids ); if( desc == slap_schema.si_ad_objectClass ) { return 0; } rc = bdb_index_param( op->o_bd, desc, LDAP_FILTER_PRESENT, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) index_param " "returned=%d\n", desc->ad_cname.bv_val, rc, 0 ); return 0; } if( db == NULL ) { /* not indexed */ Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) not indexed\n", desc->ad_cname.bv_val, 0, 0 ); return 0; } if( prefix.bv_val == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: (%s) no prefix\n", desc->ad_cname.bv_val, 0, 0 ); return -1; } rc = bdb_key_read( op->o_bd, db, NULL, &prefix, ids, NULL, 0 ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); rc = 0; } else if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_presense_candidates: (%s) " "key read failed (%d)\n", desc->ad_cname.bv_val, rc, 0 ); goto done; } Debug(LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: id=%ld first=%ld last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) );done: return rc;}static intequality_candidates( Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ){ 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}; struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates (%s)\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: (%s) " "index_param failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); return 0; } if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, "<= bdb_equality_candidates: (%s) not indexed\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); return 0; } mr = ava->aa_desc->ad_type->sat_equality; if( !mr ) { return 0; } if( !mr->smr_filter ) { return 0; } rc = (mr->smr_filter)( LDAP_FILTER_EQUALITY, mask, ava->aa_desc->ad_type->sat_syntax, mr, &prefix, &ava->aa_value, &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s, %s) " "MR filter failed (%d)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); return 0; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) no keys\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); return 0; } for ( i= 0; keys[i].bv_val != NULL; i++ ) { rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); rc = 0; break; } else if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) " "key read failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); break; } if( BDB_IDL_IS_ZERO( tmp ) ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: (%s) NULL\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ZERO( ids ); break; } if ( i == 0 ) { BDB_IDL_CPY( ids, tmp ); } else { bdb_idl_intersection( ids, tmp ); } if( BDB_IDL_IS_ZERO( ids ) ) break; } ber_bvarray_free_x( keys, op->o_tmpmemctx ); Debug( LDAP_DEBUG_TRACE, "<= bdb_equality_candidates: id=%ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); return( rc );}static intapprox_candidates( Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ){ 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}; struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates (%s)\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_APPROX, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: (%s) " "index_param failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); return 0; } if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, "<= bdb_approx_candidates: (%s) not indexed\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); return 0; } mr = ava->aa_desc->ad_type->sat_approx; if( !mr ) { /* no approx matching rule, try equality matching rule */ mr = ava->aa_desc->ad_type->sat_equality; } if( !mr ) { return 0; } if( !mr->smr_filter ) { return 0; } rc = (mr->smr_filter)( LDAP_FILTER_APPROX, mask, ava->aa_desc->ad_type->sat_syntax, mr, &prefix, &ava->aa_value, &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s, %s) " "MR filter failed (%d)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); return 0; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) no keys (%s)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, 0 ); return 0; } for ( i= 0; keys[i].bv_val != NULL; i++ ) { rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); rc = 0; break; } else if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) " "key read failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); break; } if( BDB_IDL_IS_ZERO( tmp ) ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates: (%s) NULL\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ZERO( ids ); break; } if ( i == 0 ) { BDB_IDL_CPY( ids, tmp ); } else { bdb_idl_intersection( ids, tmp ); } if( BDB_IDL_IS_ZERO( ids ) ) break; } ber_bvarray_free_x( keys, op->o_tmpmemctx ); Debug( LDAP_DEBUG_TRACE, "<= bdb_approx_candidates %ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); return( rc );}static intsubstring_candidates( Operation *op, SubstringsAssertion *sub, ID *ids, ID *tmp ){ 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}; struct berval *keys = NULL; MatchingRule *mr; Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates (%s)\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( op->o_bd, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates: (%s) " "index_param failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); return 0; } if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, "<= bdb_substring_candidates: (%s) not indexed\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); return 0; } mr = sub->sa_desc->ad_type->sat_substr; if( !mr ) { return 0; } if( !mr->smr_filter ) { return 0; } rc = (mr->smr_filter)( LDAP_FILTER_SUBSTRINGS, mask, sub->sa_desc->ad_type->sat_syntax, mr, &prefix, sub, &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) " "MR filter failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); return 0; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (0x%04lx) no keys (%s)\n", mask, sub->sa_desc->ad_cname.bv_val, 0 ); return 0; } for ( i= 0; keys[i].bv_val != NULL; i++ ) { rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp, NULL, 0 ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); rc = 0; break; } else if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) " "key read failed (%d)\n", sub->sa_desc->ad_cname.bv_val, rc, 0 ); break; } if( BDB_IDL_IS_ZERO( tmp ) ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: (%s) NULL\n", sub->sa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ZERO( ids ); break; } if ( i == 0 ) { BDB_IDL_CPY( ids, tmp ); } else { bdb_idl_intersection( ids, tmp ); } if( BDB_IDL_IS_ZERO( ids ) ) break; } ber_bvarray_free_x( keys, op->o_tmpmemctx ); Debug( LDAP_DEBUG_TRACE, "<= bdb_substring_candidates: %ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); return( rc );}static intinequality_candidates( Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp, int gtorlt ){ struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; DB *db; int rc; slap_mask_t mask; struct berval prefix = {0, NULL}; struct berval *keys = NULL; MatchingRule *mr; DBC * cursor = NULL; Debug( LDAP_DEBUG_TRACE, "=> bdb_inequality_candidates (%s)\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_ANY, "<= bdb_inequality_candidates: (%s) " "index_param failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); return 0; } if ( db == NULL ) { Debug( LDAP_DEBUG_ANY, "<= bdb_inequality_candidates: (%s) not indexed\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); return 0; } mr = ava->aa_desc->ad_type->sat_equality; if( !mr ) { return 0; } if( !mr->smr_filter ) { return 0; } rc = (mr->smr_filter)( LDAP_FILTER_EQUALITY, mask, ava->aa_desc->ad_type->sat_syntax, mr, &prefix, &ava->aa_value, &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_inequality_candidates: (%s, %s) " "MR filter failed (%d)\n", prefix.bv_val, ava->aa_desc->ad_cname.bv_val, rc ); return 0; } if( keys == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_inequality_candidates: (%s) no keys\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); return 0; } BDB_IDL_ZERO( ids ); while(1) { rc = bdb_key_read( op->o_bd, db, NULL, &keys[0], tmp, &cursor, gtorlt ); if( rc == DB_NOTFOUND ) { rc = 0; break; } else if( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_inequality_candidates: (%s) " "key read failed (%d)\n", ava->aa_desc->ad_cname.bv_val, rc, 0 ); break; } if( BDB_IDL_IS_ZERO( tmp ) ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_inequality_candidates: (%s) NULL\n", ava->aa_desc->ad_cname.bv_val, 0, 0 ); break; } bdb_idl_union( ids, tmp ); 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; } } ber_bvarray_free_x( keys, op->o_tmpmemctx ); Debug( LDAP_DEBUG_TRACE, "<= bdb_inequality_candidates: id=%ld, first=%ld, last=%ld\n", (long) ids[0], (long) BDB_IDL_FIRST(ids), (long) BDB_IDL_LAST(ids) ); return( rc );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -