]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/index.c
Added bdb_attribute and bdb_group ACL support routines
[openldap] / servers / slapd / back-bdb / index.c
index a9643a7d7ffe85deaf6379e018bc4275c328109c..aea035d4313b07a10dd9eba8673118cc5ee4cccd 100644 (file)
@@ -24,14 +24,11 @@ static slap_mask_t index_mask(
        AttributeType *at;
        slap_mask_t mask = 0;
 
-       /* we do not support indexing of binary attributes */
-       if( slap_ad_is_binary( desc ) ) return 0;
-
-       bdb_attr_mask( be->be_private, desc->ad_cname->bv_val, &mask );
+       bdb_attr_mask( be->be_private, desc->ad_cname.bv_val, &mask );
 
        if( mask ) {
-               *atname = desc->ad_cname->bv_val;
-               *dbname = desc->ad_cname->bv_val;
+               *atname = desc->ad_cname.bv_val;
+               *dbname = desc->ad_cname.bv_val;
                return mask;
        }
 
@@ -40,7 +37,7 @@ static slap_mask_t index_mask(
                bdb_attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
 
                if( mask & SLAP_INDEX_AUTO_LANG ) {
-                       *atname = desc->ad_cname->bv_val;
+                       *atname = desc->ad_cname.bv_val;
                        *dbname = desc->ad_type->sat_cname;
                        return mask;
                }
@@ -76,11 +73,13 @@ int bdb_index_param(
        Backend *be,
        AttributeDescription *desc,
        int ftype,
-       char **dbnamep,
+       DB **dbp,
        slap_mask_t *maskp,
        struct berval **prefixp )
 {
+       int rc;
        slap_mask_t mask;
+       DB *db;
        char *dbname;
        char *atname;
 
@@ -90,6 +89,12 @@ int bdb_index_param(
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
+       rc = bdb_db_cache( be, dbname, &db );
+
+       if( rc != LDAP_SUCCESS ) {
+               return rc;
+       }
+
        switch(ftype) {
        case LDAP_FILTER_PRESENT:
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
@@ -122,7 +127,7 @@ int bdb_index_param(
        return LDAP_INAPPROPRIATE_MATCHING;
 
 done:
-       *dbnamep = dbname;
+       *dbp = db;
        *prefixp = ber_bvstrdup( atname );
        *maskp = mask;
        return LDAP_SUCCESS;
@@ -240,7 +245,6 @@ static int indexer(
        }
 
 done:
-       ad_free( ad, 1 );
        return rc;
 }
 
@@ -248,7 +252,7 @@ static int index_at_values(
        Backend *be,
        DB_TXN *txn,
        AttributeType *type,
-       const char *lang,
+       struct berval *lang,
        struct berval **vals,
        ID id,
        int op,
@@ -287,13 +291,13 @@ static int index_at_values(
                if( rc ) return rc;
        }
 
-       if( lang ) {
+       if( lang->bv_len ) {
                char *dbname = NULL;
                size_t tlen = strlen( type->sat_cname );
-               size_t llen = strlen( lang );
+               size_t llen = lang->bv_len;
                char *lname = ch_malloc( tlen + llen + sizeof(";") );
 
-               sprintf( lname, "%s;%s", type->sat_cname, lang );
+               sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val );
 
                bdb_attr_mask( be->be_private, lname, &tmpmask );
 
@@ -333,13 +337,8 @@ int bdb_index_values(
        char *dbname = NULL;
        slap_mask_t mask;
 
-       if( slap_ad_is_binary( desc ) ) {
-               /* binary attributes have no index capabilities */
-               return LDAP_SUCCESS;
-       }
-
        rc = index_at_values( be, txn,
-               desc->ad_type, desc->ad_lang,
+               desc->ad_type, &desc->ad_lang,
                vals, id, op,
                &dbname, &mask );
 
@@ -358,13 +357,13 @@ bdb_index_entry(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
-               "index_entry: %s (%s)%ld\n",
+               "index_entry: %s (%s) %ld\n",
                op == SLAP_INDEX_ADD_OP ? "add" : "del",
-               e->e_dn, e->e_id ));
+               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",
-               e->e_id, e->e_dn );
+               (long) e->e_id, e->e_dn );
 #endif
 
        /* add each attribute to the indexes */
@@ -380,7 +379,7 @@ bdb_index_entry(
                        Debug( LDAP_DEBUG_TRACE,
                                "<= index_entry_%s( %ld, \"%s\" ) success\n",
                                op == SLAP_INDEX_ADD_OP ? "add" : "del",
-                               e->e_id, e->e_dn );
+                               (long) e->e_id, e->e_dn );
 #endif
                        return rc;
                }
@@ -388,11 +387,11 @@ bdb_index_entry(
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "index", LDAP_LEVEL_ENTRY,
-                  "index_entry: success\n" ));
+               "index_entry: success\n" ));
 #else
        Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n",
                op == SLAP_INDEX_ADD_OP ? "add" : "del",
-               e->e_id, e->e_dn );
+               (long) e->e_id, e->e_dn );
 #endif
 
        return LDAP_SUCCESS;