]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/index.c
More unifdef SLAPD_MULTIMASTER cleanup
[openldap] / servers / slapd / back-ldbm / index.c
index 00e1d2e6c5bb6afd8288e3a23d4cf9ecb65f9e42..6cdec8db7ef9116ce0c61f6ef935fe55f7fda4db 100644 (file)
@@ -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 <http://www.openldap.org/>.
+ *
+ * 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
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #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 );
        }
@@ -228,8 +234,6 @@ static int indexer(
 
        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;
 }