]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/index.c
NVALUES: fix a couple of value_find_ex() calls
[openldap] / servers / slapd / back-bdb / index.c
index adf07c75666507556d2a18f484ace23714c198a7..1120054eb3f8b6a7c8f670fd4ccfa8cd43f8a6d1 100644 (file)
@@ -1,7 +1,7 @@
 /* index.c - routines for dealing with attribute indexes */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -36,14 +36,14 @@ static slap_mask_t index_mask(
                return mask;
        }
 
-       /* If there is a language tag, did we ever index the base
+       /* If there is a tagging option, did we ever index the base
         * type? If so, check for mask, otherwise it's not there.
         */
-       if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) {
-               /* has language tag */
+       if( slap_ad_is_tagged( desc ) && desc != desc->ad_type->sat_ad ) {
+               /* has tagging option */
                bdb_attr_mask( be->be_private, desc->ad_type->sat_ad, &mask );
 
-               if ( mask && ( mask ^ SLAP_INDEX_NOLANG ) ) {
+               if ( mask && ( mask ^ SLAP_INDEX_NOTAGS ) ) {
                        *atname = desc->ad_type->sat_cname;
                        *dbname = desc->ad_type->sat_cname.bv_val;
                        return mask;
@@ -112,6 +112,7 @@ int bdb_index_param(
        switch( ftype ) {
        case LDAP_FILTER_PRESENT:
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
+                       *prefixp = presence_key;
                        goto done;
                }
                break;
@@ -168,8 +169,8 @@ static int indexer(
        
        if ( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "index", LDAP_LEVEL_ERR,
-                       "bdb_index_read: Could not open DB %s\n", dbname));
+               LDAP_LOG( INDEX, ERR, 
+                       "bdb_index_read: Could not open DB %s\n", dbname, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "<= bdb_index_read NULL (could not open %s)\n",
@@ -261,7 +262,7 @@ static int index_at_values(
        Backend *be,
        DB_TXN *txn,
        AttributeType *type,
-       struct berval *lang,
+       struct berval *tags,
        BerVarray vals,
        ID id,
        int op )
@@ -272,7 +273,7 @@ static int index_at_values(
        if( type->sat_sup ) {
                /* recurse */
                rc = index_at_values( be, txn,
-                       type->sat_sup, lang,
+                       type->sat_sup, tags,
                        vals, id, op );
 
                if( rc ) return rc;
@@ -292,12 +293,12 @@ static int index_at_values(
                if( rc ) return rc;
        }
 
-       if( lang->bv_len ) {
+       if( tags->bv_len ) {
                AttributeDescription *desc;
 
                mask = 0;
 
-               desc = ad_find_lang( type, lang );
+               desc = ad_find_tags( type, tags );
                if( desc ) {
                        bdb_attr_mask( be->be_private, desc, &mask );
                }
@@ -328,7 +329,7 @@ int bdb_index_values(
        int rc;
 
        rc = index_at_values( be, txn,
-               desc->ad_type, &desc->ad_lang,
+               desc->ad_type, &desc->ad_tags,
                vals, id, op );
 
        return rc;
@@ -345,10 +346,8 @@ bdb_index_entry(
        int rc;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
-               "index_entry: %s (%s) %ld\n",
-               op == SLAP_INDEX_ADD_OP ? "add" : "del",
-               e->e_dn, (long) e->e_id ));
+       LDAP_LOG( INDEX, ENTRY, "index_entry: %s (%s) %ld\n",
+               op == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_dn, (long) e->e_id );
 #else
        Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n",
                op == SLAP_INDEX_ADD_OP ? "add" : "del",
@@ -357,16 +356,22 @@ bdb_index_entry(
 
        /* add each attribute to the indexes */
        for ( ; ap != NULL; ap = ap->a_next ) {
-               rc = bdb_index_values( be, txn,
-                       ap->a_desc, ap->a_vals, e->e_id, op );
+#ifdef SLAP_NVALUES
+               rc = bdb_index_values( be, txn, ap->a_desc,
+                       ap->a_nvals ? ap->a_nvals : ap->a_vals,
+                       e->e_id, op );
+#else
+               rc = bdb_index_values( be, txn, ap->a_desc,
+                       ap->a_vals, e->e_id, op );
+#endif
 
                if( rc != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
-                               "index_entry: success\n" ));
+                       LDAP_LOG( INDEX, ENTRY, 
+                               "index_entry: failure (%d)\n", rc, 0, 0 );
 #else
                        Debug( LDAP_DEBUG_TRACE,
-                               "<= index_entry_%s( %ld, \"%s\" ) success\n",
+                               "<= index_entry_%s( %ld, \"%s\" ) failure\n",
                                op == SLAP_INDEX_ADD_OP ? "add" : "del",
                                (long) e->e_id, e->e_dn );
 #endif
@@ -375,8 +380,7 @@ bdb_index_entry(
        }
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
-               "index_entry: success\n" ));
+       LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0  );
 #else
        Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n",
                op == SLAP_INDEX_ADD_OP ? "add" : "del",