/* index.c - routines for dealing with attribute indexes */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* has language tag */
bdb_attr_mask( be->be_private, desc->ad_type->sat_ad, &mask );
- if (! ( mask & SLAP_INDEX_NOLANG ) ) {
+ if ( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) {
*atname = desc->ad_type->sat_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
bdb_attr_mask( be->be_private, at->sat_ad, &mask );
- if( mask & SLAP_INDEX_AUTO_SUBTYPES ) {
- *atname = desc->ad_type->sat_cname;
- *dbname = at->sat_cname.bv_val;
- return mask;
- }
-
- if( !( mask & SLAP_INDEX_NOSUBTYPES ) ) {
+ if ( mask && ( mask ^ SLAP_INDEX_NOSUBTYPES ) ) {
*atname = at->sat_cname;
*dbname = at->sat_cname.bv_val;
return mask;
}
-
- if( mask ) break;
}
return 0;
}
+int bdb_index_is_indexed(
+ Backend *be,
+ AttributeDescription *desc )
+{
+ slap_mask_t mask;
+ char *dbname;
+ struct berval prefix;
+
+ mask = index_mask( be, desc, &dbname, &prefix );
+
+ if( mask == 0 ) {
+ return LDAP_INAPPROPRIATE_MATCHING;
+ }
+
+ return LDAP_SUCCESS;
+}
+
int bdb_index_param(
Backend *be,
AttributeDescription *desc,
DB_TXN *txn,
char *dbname,
struct berval *atname,
- BVarray vals,
+ BerVarray vals,
ID id,
int op,
slap_mask_t mask )
for( i=0; keys[i].bv_val != NULL; i++ ) {
rc = bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
- bvarray_free( keys );
+ ber_bvarray_free( keys );
goto done;
}
}
- bvarray_free( keys );
+ ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
}
for( i=0; keys[i].bv_val != NULL; i++ ) {
rc = bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
- bvarray_free( keys );
+ ber_bvarray_free( keys );
goto done;
}
}
- bvarray_free( keys );
+ ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
for( i=0; keys[i].bv_val != NULL; i++ ) {
bdb_key_change( be, db, txn, &keys[i], id, op );
if( rc ) {
- bvarray_free( keys );
+ ber_bvarray_free( keys );
goto done;
}
}
- bvarray_free( keys );
+ ber_bvarray_free( keys );
}
rc = LDAP_SUCCESS;
DB_TXN *txn,
AttributeType *type,
struct berval *lang,
- BVarray vals,
+ BerVarray vals,
ID id,
- int op,
- char ** dbnamep,
- slap_mask_t *maskp )
+ int op )
{
int rc;
slap_mask_t mask = 0;
- slap_mask_t tmpmask = 0;
- int lindex = 0;
if( type->sat_sup ) {
/* recurse */
rc = index_at_values( be, txn,
type->sat_sup, lang,
- vals, id, op,
- dbnamep, &tmpmask );
+ vals, id, op );
if( rc ) return rc;
}
}
if( mask ) {
- *dbnamep = type->sat_cname.bv_val;
- } else if ( !( tmpmask & SLAP_INDEX_AUTO_SUBTYPES ) ) {
- mask = tmpmask;
- }
-
- if( mask ) {
- rc = indexer( be, txn, *dbnamep,
+ rc = indexer( be, txn, type->sat_cname.bv_val,
&type->sat_cname,
vals, id, op,
mask );
}
if( lang->bv_len ) {
- char *dbname = NULL;
- struct berval lname;
AttributeDescription *desc;
- tmpmask = 0;
- lname.bv_val = NULL;
+ mask = 0;
desc = ad_find_lang( type, lang );
if( desc ) {
- bdb_attr_mask( be->be_private, desc, &tmpmask );
+ bdb_attr_mask( be->be_private, desc, &mask );
}
- if( tmpmask ) {
- dbname = desc->ad_cname.bv_val;
- lname = desc->ad_cname;
- mask = tmpmask;
- }
-
- if( dbname != NULL ) {
- rc = indexer( be, txn, dbname, &lname,
+ if( mask ) {
+ rc = indexer( be, txn, desc->ad_cname.bv_val,
+ &desc->ad_cname,
vals, id, op,
mask );
- if( !tmpmask ) {
- ch_free( lname.bv_val );
- }
if( rc ) {
return rc;
}
Backend *be,
DB_TXN *txn,
AttributeDescription *desc,
- BVarray vals,
+ BerVarray vals,
ID id,
int op )
{
int rc;
- char *dbname = NULL;
- slap_mask_t mask;
rc = index_at_values( be, txn,
desc->ad_type, &desc->ad_lang,
- vals, id, op,
- &dbname, &mask );
+ vals, id, op );
return rc;
}