X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldbm%2Findex.c;h=6cdec8db7ef9116ce0c61f6ef935fe55f7fda4db;hb=324431062bff39a1bd3969bd37d4913526dd583f;hp=00e6c6a37523a7389ea95dc47830cca3c403a433;hpb=ece7452b05fcbbb14823e113b683365a59f81f05;p=openldap
diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c
index 00e6c6a375..6cdec8db7e 100644
--- a/servers/slapd/back-ldbm/index.c
+++ b/servers/slapd/back-ldbm/index.c
@@ -1,8 +1,17 @@
/* index.c - routines for dealing with attribute indexes */
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
#include "portable.h"
@@ -106,9 +115,14 @@ int index_param(
break;
case LDAP_FILTER_APPROX:
- if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
- goto done;
+ if ( desc->ad_type->sat_approx ) {
+ if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
+ goto done;
+ }
+ break;
}
+
+ /* Use EQUALITY rule and index for approximate match */
/* fall thru */
case LDAP_FILTER_EQUALITY:
@@ -146,10 +160,9 @@ static int indexer(
{
int rc, i;
const char *text;
- DBCache *db;
+ DBCache *db;
AttributeDescription *ad = NULL;
struct berval *keys;
- void *mark;
assert( mask );
@@ -160,20 +173,13 @@ static int indexer(
db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT );
if ( db == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG( INDEX, ERR,
- "index_read: Could not open db %s%s\n", dbname, LDBM_SUFFIX, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"<= index_read NULL (could not open %s%s)\n",
dbname, LDBM_SUFFIX, 0 );
-#endif
return LDAP_OTHER;
}
- mark = sl_mark( op->o_tmpmemctx );
-
if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
key_change( op->o_bd, db, atname, id, opid );
}
@@ -190,7 +196,7 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
key_change( op->o_bd, db, &keys[i], id, opid );
}
- ber_bvarray_free( keys );
+ ber_bvarray_free_x( keys, op->o_tmpmemctx );
}
}
@@ -206,7 +212,7 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
key_change( op->o_bd, db, &keys[i], id, opid );
}
- ber_bvarray_free( keys );
+ ber_bvarray_free_x( keys, op->o_tmpmemctx );
}
}
@@ -222,14 +228,12 @@ static int indexer(
for( i=0; keys[i].bv_val != NULL; i++ ) {
key_change( op->o_bd, db, &keys[i], id, opid );
}
- ber_bvarray_free( keys );
+ ber_bvarray_free_x( keys, op->o_tmpmemctx );
}
}
ldbm_cache_close( op->o_bd, db );
- sl_release( mark, op->o_tmpmemctx );
-
return LDAP_SUCCESS;
}
@@ -303,15 +307,9 @@ index_entry(
Entry *e )
{
Attribute *ap = e->e_attrs;
-#ifdef NEW_LOGGING
- LDAP_LOG( INDEX, ENTRY,
- "index_entry: %s (%s)%ld\n", opid == SLAP_INDEX_ADD_OP ? "add" : "del",
- e->e_dn, e->e_id );
-#else
Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n",
opid == SLAP_INDEX_ADD_OP ? "add" : "del",
e->e_id, e->e_dn );
-#endif
/* add each attribute to the indexes */
for ( ; ap != NULL; ap = ap->a_next ) {
@@ -320,13 +318,9 @@ index_entry(
e->e_id, opid );
}
-#ifdef NEW_LOGGING
- LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n",
opid == SLAP_INDEX_ADD_OP ? "add" : "del",
e->e_id, e->e_dn );
-#endif
return LDAP_SUCCESS;
}