Rework indexing code, removing "autolang" and making

"subtypes" and "lang" default behavior.
This commit is contained in:
Kurt Zeilenga 2001-12-05 00:06:03 +00:00
parent fe92783ea8
commit 493b415255
7 changed files with 731 additions and 766 deletions

1377
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -10,20 +10,16 @@ ldap_friendly_name, ldap_free_friendlymap \- LDAP unfriendly to friendly name ma
#include <ldap.h>
.LP
.ft B
typedef struct ldap_friendly {
char *lf_unfriendly;
char *lf_friendly;
} LDAPFriendlyMap;
typedef struct ldap_friendly LDAPFriendlyMap;
.LP
.ft B
char *ldap_friendly_name(filename, name, map)
.ft
char *filename;
char *name;
LDAPFriendlyMap **map;
const char *ldap_friendly_name(
const char *filename,
const char *name,
LDAPFriendlyMap **map)
.LP
.ft B
void ldap_free_friendlymap(map)
void ldap_free_friendlymap( LDAPFriendlyMap **map )
.ft
LDAPFriendlyMap **map;
.SH DESCRIPTION

View file

@ -837,19 +837,15 @@ can be decomposed into
.B subfinal
indices.
The special type
.B lang
may be specified to allow use of this index by language subtypes.
.B nolang
may be specified to disallow use of this index by language subtypes.
The special type
.B autolang
may be specified to automatically maintain separate indices for each
language subtypes.
The special type
.B subtypes
may be specified to allow use of this index by named subtypes.
.B nosubtypes
may be specified to disallow use of this index by named subtypes.
The special type
.B autosubtypes
may be specified to automatically maintain separate indices for each
other subtypes.
named subtype of the attribute type.
.TP
.B mode <integer>
Specify the file protection mode that newly created database

View file

@ -39,12 +39,7 @@ static slap_mask_t index_mask(
/* has language tag */
bdb_attr_mask( be->be_private, desc->ad_type->sat_ad, &mask );
if( mask & SLAP_INDEX_AUTO_LANG ) {
*atname = desc->ad_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_LANG ) {
if (! ( mask & SLAP_INDEX_NOLANG ) ) {
*atname = desc->ad_type->sat_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
@ -54,8 +49,7 @@ static slap_mask_t index_mask(
/* see if supertype defined mask for its subtypes */
for( at = desc->ad_type; at != NULL ; at = at->sat_sup ) {
/* If no AD, we've never indexed this type */
if (!at->sat_ad)
continue;
if ( !at->sat_ad ) continue;
bdb_attr_mask( be->be_private, at->sat_ad, &mask );
@ -64,7 +58,8 @@ static slap_mask_t index_mask(
*dbname = at->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_SUBTYPES ) {
if( !( mask & SLAP_INDEX_NOSUBTYPES ) ) {
*atname = at->sat_cname;
*dbname = at->sat_cname.bv_val;
return mask;
@ -101,7 +96,7 @@ int bdb_index_param(
return rc;
}
switch(ftype) {
switch( ftype ) {
case LDAP_FILTER_PRESENT:
if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
goto done;
@ -276,12 +271,13 @@ static int index_at_values(
}
/* If this type has no AD, we've never used it before */
if (type->sat_ad)
if( type->sat_ad ) {
bdb_attr_mask( be->be_private, type->sat_ad, &mask );
}
if( mask ) {
*dbnamep = type->sat_cname.bv_val;
} else if ( tmpmask & SLAP_INDEX_AUTO_SUBTYPES ) {
} else if ( !( tmpmask & SLAP_INDEX_AUTO_SUBTYPES ) ) {
mask = tmpmask;
}
@ -303,21 +299,14 @@ static int index_at_values(
lname.bv_val = NULL;
desc = ad_find_lang( type, lang );
if (desc)
if( desc ) {
bdb_attr_mask( be->be_private, desc, &tmpmask );
}
if( tmpmask ) {
dbname = desc->ad_cname.bv_val;
lname = desc->ad_cname;
mask = tmpmask;
} else if ( mask & SLAP_INDEX_AUTO_LANG ) {
dbname = *dbnamep;
lname.bv_len = type->sat_cname.bv_len+lang->bv_len + 1;
lname.bv_val = ch_malloc( lname.bv_len + 1 );
strcpy(lname.bv_val, type->sat_cname.bv_val);
lname.bv_val[type->sat_cname.bv_len] = ';';
strcpy(lname.bv_val+type->sat_cname.bv_len+1,
lang->bv_val);
}
if( dbname != NULL ) {
@ -325,8 +314,9 @@ static int index_at_values(
vals, id, op,
mask );
if (!tmpmask)
if( !tmpmask ) {
ch_free( lname.bv_val );
}
if( rc ) {
return rc;
}

View file

@ -39,12 +39,7 @@ static slap_mask_t index_mask(
/* has language tag */
attr_mask( be->be_private, desc->ad_type->sat_ad, &mask );
if( mask & SLAP_INDEX_AUTO_LANG ) {
*atname = desc->ad_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_LANG ) {
if( !( mask & SLAP_INDEX_NOLANG ) ) {
*atname = desc->ad_type->sat_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
@ -64,7 +59,7 @@ static slap_mask_t index_mask(
*dbname = at->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_SUBTYPES ) {
if( !( mask & SLAP_INDEX_NOSUBTYPES ) ) {
*atname = at->sat_cname;
*dbname = at->sat_cname.bv_val;
return mask;
@ -93,7 +88,7 @@ int index_param(
return LDAP_INAPPROPRIATE_MATCHING;
}
switch(ftype) {
switch( ftype ) {
case LDAP_FILTER_PRESENT:
if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
goto done;
@ -245,8 +240,9 @@ static int index_at_values(
}
/* If this type has no AD, we've never used it before */
if (type->sat_ad)
if( type->sat_ad ) {
attr_mask( be->be_private, type->sat_ad, &mask );
}
if( mask ) {
*dbnamep = type->sat_cname.bv_val;
@ -270,30 +266,23 @@ static int index_at_values(
lname.bv_val = NULL;
desc = ad_find_lang(type, lang);
if (desc)
if( desc ) {
attr_mask( be->be_private, desc, &tmpmask );
}
if( tmpmask ) {
dbname = desc->ad_cname.bv_val;
lname = desc->ad_cname;
mask = tmpmask;
} else if ( mask & SLAP_INDEX_AUTO_LANG ) {
dbname = *dbnamep;
lname.bv_len = type->sat_cname.bv_len+lang->bv_len + 1;
lname.bv_val = ch_malloc( lname.bv_len + 1 );
strcpy(lname.bv_val, type->sat_cname.bv_val);
lname.bv_val[type->sat_cname.bv_len] = ';';
strcpy(lname.bv_val+type->sat_cname.bv_len+1,
lang->bv_val);
}
if( dbname != NULL ) {
indexer( be, dbname, &lname,
vals, id, op,
mask );
if (!tmpmask)
if( !tmpmask ) {
ch_free( lname.bv_val );
}
}
}
@ -318,14 +307,12 @@ int index_values(
return LDAP_SUCCESS;
}
int
index_entry(
Backend *be,
int op,
Entry *e,
Attribute *ap
)
Entry *e,
Attribute *ap )
{
#ifdef NEW_LOGGING
LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
@ -338,7 +325,6 @@ index_entry(
e->e_id, e->e_dn );
#endif
/* add each attribute to the indexes */
for ( ; ap != NULL; ap = ap->a_next ) {
index_values( be, ap->a_desc, ap->a_vals, e->e_id, op );
@ -353,7 +339,6 @@ index_entry(
e->e_id, e->e_dn );
#endif
return LDAP_SUCCESS;
}

View file

@ -52,12 +52,10 @@ int slap_str2index( const char *str, slap_mask_t *idx )
strcasecmp( str, "sub" ) == 0 )
{
*idx = SLAP_INDEX_SUBSTR_DEFAULT;
} else if ( strcasecmp( str, "lang" ) == 0 ) {
*idx = SLAP_INDEX_LANG;
} else if ( strcasecmp( str, "autolang" ) == 0 ) {
*idx = SLAP_INDEX_AUTO_LANG;
} else if ( strcasecmp( str, "subtypes" ) == 0 ) {
*idx = SLAP_INDEX_SUBTYPES;
} else if ( strcasecmp( str, "nolang" ) == 0 ) {
*idx = SLAP_INDEX_NOLANG;
} else if ( strcasecmp( str, "nosubtypes" ) == 0 ) {
*idx = SLAP_INDEX_NOSUBTYPES;
} else if ( strcasecmp( str, "autosubtypes" ) == 0 ) {
*idx = SLAP_INDEX_AUTO_SUBTYPES;
} else {

View file

@ -177,11 +177,10 @@ typedef struct slap_ssf_set {
#define SLAP_INDEX_SUBSTR_MAXLEN 4
#define SLAP_INDEX_SUBSTR_STEP 2
#define SLAP_INDEX_FLAGS 0xF000UL
#define SLAP_INDEX_SUBTYPES 0x1000UL /* use index with subtypes */
#define SLAP_INDEX_AUTO_SUBTYPES 0x2000UL /* use mask with subtypes */
#define SLAP_INDEX_LANG 0x4000UL /* use index with lang subtypes */
#define SLAP_INDEX_AUTO_LANG 0x8000UL /* use mask with lang subtypes */
#define SLAP_INDEX_FLAGS 0xF000UL
#define SLAP_INDEX_NOSUBTYPES 0x1000UL /* don't use index w/ subtypes */
#define SLAP_INDEX_NOLANG 0x2000UL /* don't use index w/ lang */
#define SLAP_INDEX_AUTO_SUBTYPES 0x4000UL /* use mask with lang subtypes */
/*
* there is a single index for each attribute. these prefixes ensure