]> git.sur5r.net Git - openldap/commitdiff
filter_candidate tweaks, search_stack tweaks
authorHoward Chu <hyc@openldap.org>
Tue, 22 Apr 2003 18:22:51 +0000 (18:22 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 22 Apr 2003 18:22:51 +0000 (18:22 +0000)
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/filterindex.c
servers/slapd/back-bdb/proto-bdb.h
servers/slapd/back-bdb/search.c

index abb1161bce5447f2bd89ed42668c9ad81abbe707..4dea214cd4ead4bda2a5ddf5fc803b4ac5300b27 100644 (file)
@@ -417,6 +417,7 @@ bdb_dn2idl(
        struct berval   *dn,
        int prefix,
        ID *ids,
+       ID *stack,
        void *ctx )
 {
        int             rc;
@@ -871,7 +872,9 @@ struct dn2id_cookie {
        ID id;
        ID dbuf;
        ID *ids;
+       void *ptr;
        ID tmp[BDB_IDL_DB_SIZE];
+       ID *buf;
        DBT key;
        DBT data;
        DBC *dbc;
@@ -900,15 +903,33 @@ bdb_dn2idl_internal(
        if ( cx->rc ) return cx->rc;
        BDB_IDL_ZERO( cx->tmp );
 
+       cx->data.data = &cx->dbuf;
+       cx->data.ulen = sizeof(ID);
+       cx->data.dlen = sizeof(ID);
+       cx->data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
+
        /* The first item holds the parent ID. Ignore it. */
        cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data, DB_SET );
        if ( cx->rc == DB_NOTFOUND ) goto saveit;
        if ( cx->rc ) return cx->rc;
 
+       cx->data.data = cx->buf;
+       cx->data.ulen = BDB_IDL_UM_SIZE * sizeof(ID);
+       cx->data.flags = DB_DBT_USERMEM;
+
        /* Fetch the rest of the IDs in a loop... */
        while ( (cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data,
-               DB_NEXT_DUP )) == 0 ) {
-               bdb_idl_insert( cx->tmp, cx->dbuf );
+               DB_MULTIPLE | DB_NEXT_DUP )) == 0 ) {
+               u_int8_t *j;
+               size_t len;
+               DB_MULTIPLE_INIT( cx->ptr, &cx->data );
+               while (cx->ptr) {
+                       DB_MULTIPLE_NEXT( cx->ptr, &cx->data, j, len );
+                       if (j) {
+                               AC_MEMCPY( &cx->dbuf, j, sizeof(ID) );
+                               bdb_idl_insert( cx->tmp, cx->dbuf );
+                       }
+               }
        }
        cx->dbc->c_close( cx->dbc );
 
@@ -952,16 +973,26 @@ bdb_dn2idl(
        struct berval   *dn,
        int prefix,
        ID *ids,
+       ID *stack,
        void *ctx )
 {
        struct dn2id_cookie cx;
+       EntryInfo *ei = (EntryInfo *)dn;
 
-       cx.id = *(ID *)dn;
+#ifndef BDB_MULTIPLE_SUFFIXES
+       if ( ei->bei_parent->bei_id == 0 ) {
+               struct bdb_info *bdb = (struct bdb_info *)be->be_private;
+               BDB_IDL_ALL( bdb, ids );
+               return 0;
+       }
+#endif
 
+       cx.id = ei->bei_id;
        cx.bdb = (struct bdb_info *)be->be_private;
        cx.db = cx.bdb->bi_dn2id->bdi_db;
        cx.prefix = prefix;
        cx.ids = ids;
+       cx.buf = stack;
        cx.ctx = ctx;
 
        BDB_IDL_ZERO( ids );
@@ -976,10 +1007,6 @@ bdb_dn2idl(
        cx.key.flags = DB_DBT_USERMEM;
 
        DBTzero(&cx.data);
-       cx.data.data = &cx.dbuf;
-       cx.data.ulen = sizeof(ID);
-       cx.data.dlen = sizeof(ID);
-       cx.data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
 
        return bdb_dn2idl_internal(&cx);
 }
index 24b2cbe843c407fc2a012078d56455337711394a..0322c4ea087bc7eaf8360ec57ee5088008a1934c 100644 (file)
@@ -68,7 +68,7 @@ bdb_filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
 #endif
                rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids,
-                       op->o_tmpmemctx );
+                       stack, op->o_tmpmemctx );
                if( rc == DB_NOTFOUND ) {
                        BDB_IDL_ZERO( ids );
                        rc = 0;
@@ -82,7 +82,7 @@ bdb_filter_candidates(
                Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
 #endif
                rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
-                       op->o_tmpmemctx );
+                       stack, op->o_tmpmemctx );
                break;
 
        case LDAP_FILTER_PRESENT:
index f8e1256d260b28eba02ab431b36bfaa2ba287ba0..133ce9812a2e08ef01c4cdf0ddab64794918730c 100644 (file)
@@ -91,6 +91,7 @@ bdb_dn2idl(
        struct berval   *dn,
        int prefix,
        ID *ids,
+       ID *stack,
        void *ctx );
 
 #ifdef BDB_HIER
index 614a642b58c1fb1374261d6821e3c3476d11aa09..fa98e441f4909ac67dffc726566f1868ddb9875f 100644 (file)
@@ -268,16 +268,16 @@ nextido:
                 * we should never see the ID of an entry that doesn't exist.
                 * Set the name so that the scope's IDL can be retrieved.
                 */
-#ifndef BDB_HIER
                ei = NULL;
                rs->sr_err = bdb_cache_find_entry_id(op->o_bd, NULL, ido, &ei,
                        0, locker, &locka, op->o_tmpmemctx );
                if (rs->sr_err != LDAP_SUCCESS) goto nextido;
                e = ei->bei_e;
+#ifndef BDB_HIER
                sf->f_dn = &e->e_nname;
 #else
                /* bdb_dn2idl uses IDs for keys, not DNs */
-               sf->f_dn = (struct berval *)&ido;
+               sf->f_dn = (struct berval *)ei;
 #endif
        }
        return rs->sr_err;
@@ -662,6 +662,7 @@ dn2entry_retry:
        /* Copy info to base, must free entry before accessing the database
         * in search_candidates, to avoid deadlocks.
         */
+       base.e_private = e->e_private;
        base.e_nname = realbase;
        base.e_id = e->e_id;
 
@@ -1520,7 +1521,7 @@ static int search_candidates(
                ? SLAPD_FILTER_DN_SUBTREE
                : SLAPD_FILTER_DN_ONE;
 #ifdef BDB_HIER
-       scopef.f_dn = (struct berval *)&e->e_id;
+       scopef.f_dn = (struct berval *)e->e_private;
 #else
        scopef.f_dn = &e->e_nname;
 #endif