X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Findex.c;h=de4cf3d8363c3bb17e5d08da083252a18233ce3b;hb=f96e6378d6cd06c744a47af5e5e551cbb494826a;hp=ffa2f27ce0e8a432c2cc70ceb2c3934cebaca07a;hpb=5de908e7e18bbd992f0dec5def4eee3c438fe361;p=openldap
diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c
index ffa2f27ce0..de4cf3d836 100644
--- a/servers/slapd/back-bdb/index.c
+++ b/servers/slapd/back-bdb/index.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * 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
@@ -48,7 +48,7 @@ static AttrInfo *index_mask(
/* has tagging option */
ai = bdb_attr_mask( be->be_private, desc->ad_type->sat_ad );
- if ( ai && ( ai->ai_indexmask ^ SLAP_INDEX_NOTAGS ) ) {
+ if ( ai && !( ai->ai_indexmask & SLAP_INDEX_NOTAGS ) ) {
*atname = desc->ad_type->sat_cname;
return ai;
}
@@ -61,7 +61,7 @@ static AttrInfo *index_mask(
ai = bdb_attr_mask( be->be_private, at->sat_ad );
- if ( ai && ( ai->ai_indexmask ^ SLAP_INDEX_NOSUBTYPES ) ) {
+ if ( ai && !( ai->ai_indexmask & SLAP_INDEX_NOSUBTYPES ) ) {
*atname = at->sat_cname;
return ai;
}
@@ -170,7 +170,7 @@ static int indexer(
DB *db;
struct berval *keys;
- assert( mask );
+ assert( mask != 0 );
rc = bdb_db_cache( op->o_bd, atname->bv_val, &db );
@@ -254,6 +254,16 @@ static int indexer(
}
done:
+ switch( rc ) {
+ /* The callers all know how to deal with these results */
+ case 0:
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ break;
+ /* Anything else is bad news */
+ default:
+ rc = LDAP_OTHER;
+ }
return rc;
}
@@ -294,7 +304,7 @@ static int index_at_values(
ComponentReference *cr;
for( cr = ai->ai_cr ; cr ; cr = cr->cr_next ) {
rc = indexer( op, txn, cr->cr_ad, &type->sat_cname,
- cr->cr_nvals, id, opid,
+ cr->cr_nvals, id, ixop,
cr->cr_indexmask );
}
}
@@ -367,6 +377,80 @@ int bdb_index_values(
return rc;
}
+/* Get the list of which indices apply to this attr */
+int
+bdb_index_recset(
+ struct bdb_info *bdb,
+ Attribute *a,
+ AttributeType *type,
+ struct berval *tags,
+ IndexRec *ir )
+{
+ int rc, slot;
+ AttrList *al;
+
+ if( type->sat_sup ) {
+ /* recurse */
+ rc = bdb_index_recset( bdb, a, type->sat_sup, tags, ir );
+ if( rc ) return rc;
+ }
+ /* If this type has no AD, we've never used it before */
+ if( type->sat_ad ) {
+ slot = bdb_attr_slot( bdb, type->sat_ad, NULL );
+ if ( slot >= 0 ) {
+ ir[slot].ai = bdb->bi_attrs[slot];
+ al = ch_malloc( sizeof( AttrList ));
+ al->attr = a;
+ al->next = ir[slot].attrs;
+ ir[slot].attrs = al;
+ }
+ }
+ if( tags->bv_len ) {
+ AttributeDescription *desc;
+
+ desc = ad_find_tags( type, tags );
+ if( desc ) {
+ slot = bdb_attr_slot( bdb, desc, NULL );
+ if ( slot >= 0 ) {
+ ir[slot].ai = bdb->bi_attrs[slot];
+ al = ch_malloc( sizeof( AttrList ));
+ al->attr = a;
+ al->next = ir[slot].attrs;
+ ir[slot].attrs = al;
+ }
+ }
+ }
+ return LDAP_SUCCESS;
+}
+
+/* Apply the indices for the recset */
+int bdb_index_recrun(
+ Operation *op,
+ struct bdb_info *bdb,
+ IndexRec *ir0,
+ ID id,
+ int base )
+{
+ IndexRec *ir;
+ AttrList *al;
+ int i, rc = 0;
+
+ for (i=base; ibi_nattrs; i+=slap_tool_thread_max) {
+ ir = ir0 + i;
+ if ( !ir->ai ) continue;
+ while (( al = ir->attrs )) {
+ ir->attrs = al->next;
+ rc = indexer( op, NULL, ir->ai->ai_desc,
+ &ir->ai->ai_desc->ad_type->sat_cname,
+ al->attr->a_nvals, id, SLAP_INDEX_ADD_OP,
+ ir->ai->ai_indexmask );
+ free( al );
+ if ( rc ) break;
+ }
+ }
+ return rc;
+}
+
int
bdb_index_entry(
Operation *op,
@@ -379,7 +463,7 @@ bdb_index_entry(
#ifdef LDAP_COMP_MATCH
ComponentReference *cr_list = NULL;
ComponentReference *cr = NULL, *dupped_cr = NULL;
- void* decoded_comp, *extracted_comp;
+ void* decoded_comp;
ComponentSyntaxInfo* csi_attr;
Syntax* syn;
AttributeType* at;