From: Howard Chu Date: Sat, 24 Nov 2001 12:41:54 +0000 (+0000) Subject: More indexing fixes. Now passes tests 0-7, 10, and 11. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~838 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=df28982b43bc3287d18eae106e69f2ad585cea7e;p=openldap More indexing fixes. Now passes tests 0-7, 10, and 11. --- diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index d9ee1f4717..d429cd3be6 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -45,6 +45,7 @@ bdb_filter_candidates( Filter *f, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; int rc = -1; Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 ); @@ -94,6 +95,8 @@ bdb_filter_candidates( case LDAP_FILTER_NOT: /* no indexing to support NOT filters */ Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 ); + BDB_IDL_ALL( bdb, ids ); + rc = 0; break; case LDAP_FILTER_AND: @@ -111,6 +114,7 @@ bdb_filter_candidates( default: Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %d\n", f->f_choice, 0, 0 ); + BDB_IDL_ALL( bdb, ids ); } Debug( LDAP_DEBUG_FILTER, @@ -129,6 +133,7 @@ list_candidates( int ftype, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; int rc = 0; Filter *f; ID tmp[BDB_IDL_UM_SIZE]; @@ -144,8 +149,10 @@ list_candidates( i2 = save; i3 = tmp; + BDB_IDL_ZERO( tmp ); + for ( f = flist; f != NULL; f = f->f_next ) { - BDB_IDL_ZERO( i1 ); + BDB_IDL_ZERO( i2 ); rc = bdb_filter_candidates( be, f, i2 ); if ( rc != 0 ) { @@ -195,13 +202,14 @@ presence_candidates( AttributeDescription *desc, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db; int rc; slap_mask_t mask; struct berval prefix = {0}; Debug( LDAP_DEBUG_TRACE, "=> bdb_presence_candidates\n", 0, 0, 0 ); - BDB_IDL_ZERO( ids ); + BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( be, desc, LDAP_FILTER_PRESENT, &db, &mask, &prefix ); @@ -210,7 +218,7 @@ presence_candidates( Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: index_param returned=%d\n", rc, 0, 0 ); - return rc; + return 0; } if( db == NULL ) { @@ -218,16 +226,14 @@ presence_candidates( Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: not indexed\n", 0, 0, 0 ); - rc = -1; - goto done; + return 0; } if( prefix.bv_val == NULL ) { Debug( LDAP_DEBUG_TRACE, "<= bdb_presence_candidates: no prefix\n", 0, 0, 0 ); - rc = -1; - goto done; + return 0; } rc = bdb_key_read( be, db, NULL, &prefix, ids ); @@ -258,6 +264,7 @@ equality_candidates( AttributeAssertion *ava, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db; int i; int rc; @@ -270,7 +277,7 @@ equality_candidates( ID *i1, *i2, *i3, *t; Debug( LDAP_DEBUG_TRACE, "=> bdb_equality_candidates\n", 0, 0, 0 ); - BDB_IDL_ZERO( ids ); + BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY, &db, &mask, &prefix ); @@ -326,6 +333,9 @@ equality_candidates( i1 = ids; i2 = save; i3 = tmp; + + BDB_IDL_ALL( bdb, tmp ); + for ( i= 0; keys[i] != NULL; i++ ) { rc = bdb_key_read( be, db, NULL, keys[i], i2 ); @@ -397,6 +407,7 @@ approx_candidates( AttributeAssertion *ava, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db; int i; int rc; @@ -409,7 +420,7 @@ approx_candidates( ID *i1, *i2, *i3, *t; Debug( LDAP_DEBUG_TRACE, "=> bdb_approx_candidates\n", 0, 0, 0 ); - BDB_IDL_ZERO( ids ); + BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( be, ava->aa_desc, LDAP_FILTER_APPROX, &db, &mask, &prefix ); @@ -470,6 +481,9 @@ approx_candidates( i1 = ids; i2 = save; i3 = tmp; + + BDB_IDL_ALL( bdb, tmp ); + for ( i= 0; keys[i] != NULL; i++ ) { rc = bdb_key_read( be, db, NULL, keys[i], i2 ); @@ -529,6 +543,7 @@ substring_candidates( SubstringsAssertion *sub, ID *ids ) { + struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB *db; int i; int rc; @@ -541,7 +556,7 @@ substring_candidates( ID *i1, *i2, *i3, *t; Debug( LDAP_DEBUG_TRACE, "=> bdb_substring_candidates\n", 0, 0, 0 ); - BDB_IDL_ZERO( ids ); + BDB_IDL_ALL( bdb, ids ); rc = bdb_index_param( be, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, &db, &mask, &prefix ); @@ -599,6 +614,9 @@ substring_candidates( i1 = ids; i2 = save; i3 = tmp; + + BDB_IDL_ALL( bdb, tmp ); + for ( i= 0; keys[i] != NULL; i++ ) { rc = bdb_key_read( be, db, NULL, keys[i], i2 ); diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index c579511de8..5a4412240a 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -323,10 +323,16 @@ bdb_idl_insert_key( } else { rc = idl_insert( ids, id ); + if( rc == -1 ) { + Debug( LDAP_DEBUG_TRACE, "=> bdb_idl_insert_key: dup\n", + 0, 0, 0 ); + return 0; + } if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: " "idl_insert failed (%d)\n", rc, 0, 0 ); + return rc; } @@ -471,7 +477,7 @@ bdb_idl_intersection( ids[0] = 0; - while( ida != NOID && idb != NOID ) { + while( ida != NOID || idb != NOID ) { if( ida == idb ) { ids[++ids[0]] = ida; ida = bdb_idl_next( a, &cursora ); @@ -529,7 +535,7 @@ bdb_idl_union( ids[0] = 0; - while( ida != NOID && idb != NOID ) { + while( ida != NOID || idb != NOID ) { if( ++ids[0] > BDB_IDL_UM_MAX ) { ids[0] = NOID; ids[2] = IDL_MAX( BDB_IDL_LAST(a), BDB_IDL_LAST(b) ); diff --git a/servers/slapd/back-bdb/idl.h b/servers/slapd/back-bdb/idl.h index 2eac4c6b50..d91296aa6c 100644 --- a/servers/slapd/back-bdb/idl.h +++ b/servers/slapd/back-bdb/idl.h @@ -28,8 +28,8 @@ #define BDB_IDL_IS_RANGE(ids) ((ids)[0] == NOID) #define BDB_IDL_RANGE_SIZE (3) #define BDB_IDL_RANGE_SIZEOF (BDB_IDL_RANGE_SIZE * sizeof(ID)) -#define BDB_IDL_SIZEOF(ids) (BDB_IDL_IS_RANGE(ids) \ - ? BDB_IDL_RANGE_SIZE : ((ids)[0]+1) * sizeof(ID)) +#define BDB_IDL_SIZEOF(ids) ((BDB_IDL_IS_RANGE(ids) \ + ? BDB_IDL_RANGE_SIZE : ((ids)[0]+1)) * sizeof(ID)) #define BDB_IDL_RANGE_FIRST(ids) ((ids)[1]) #define BDB_IDL_RANGE_LAST(ids) ((ids)[2])