1 /* dn2id.c - routines to deal with the dn2id index */
4 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
25 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
26 DB *db = bdb->bi_dn2id->bdi_db;
30 struct berval ptr, pdn;
33 LDAP_LOG ( INDEX, ARGS, "bdb_dn2id_add( \"%s\", 0x%08lx )\n",
34 e->e_ndn, (long) e->e_id, 0 );
36 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n",
37 e->e_ndn, (long) e->e_id, 0 );
39 assert( e->e_id != NOID );
42 key.size = e->e_nname.bv_len + 2;
44 key.flags = DB_DBT_USERMEM;
45 buf = ch_malloc( key.size );
47 buf[0] = DN_BASE_PREFIX;
49 ptr.bv_len = e->e_nname.bv_len;
50 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
51 ptr.bv_val[ptr.bv_len] = '\0';
54 data.data = (char *) &e->e_id;
55 data.size = sizeof( e->e_id );
57 /* store it -- don't override */
58 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
61 LDAP_LOG ( INDEX, ERR, "bdb_dn2id_add: put failed: %s %d\n",
62 db_strerror(rc), rc, 0 );
64 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n",
65 db_strerror(rc), rc, 0 );
70 if( !be_issuffix( be, &ptr )) {
71 buf[0] = DN_SUBTREE_PREFIX;
72 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
75 LDAP_LOG ( INDEX, ERR,
76 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
79 Debug( LDAP_DEBUG_ANY,
80 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
86 dnParent( &ptr, &pdn );
88 key.size = pdn.bv_len + 2;
90 pdn.bv_val[-1] = DN_ONE_PREFIX;
91 key.data = pdn.bv_val-1;
94 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
98 LDAP_LOG ( INDEX, ERR,
99 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
102 Debug( LDAP_DEBUG_ANY,
103 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
110 while( !be_issuffix( be, &ptr )) {
111 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
113 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
117 LDAP_LOG ( INDEX, ERR,
118 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
121 Debug( LDAP_DEBUG_ANY,
122 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
127 dnParent( &ptr, &pdn );
129 key.size = pdn.bv_len + 2;
131 key.data = pdn.bv_val - 1;
138 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
140 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
152 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
153 DB *db = bdb->bi_dn2id->bdi_db;
157 struct berval pdn, ptr;
160 LDAP_LOG ( INDEX, ARGS,
161 "=> bdb_dn2id_delete ( \"%s\", 0x%08lx )\n", e->e_ndn, e->e_id, 0);
163 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", 0x%08lx )\n",
164 e->e_ndn, e->e_id, 0 );
168 key.size = e->e_nname.bv_len + 2;
169 buf = ch_malloc( key.size );
171 key.flags = DB_DBT_USERMEM;
172 buf[0] = DN_BASE_PREFIX;
174 ptr.bv_len = e->e_nname.bv_len;
175 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
176 ptr.bv_val[ptr.bv_len] = '\0';
179 rc = db->del( db, txn, &key, 0 );
182 LDAP_LOG ( INDEX, ERR,
183 "=> bdb_dn2id_delete: delete failed: %s %d\n",
184 db_strerror(rc), rc, 0 );
186 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n",
187 db_strerror(rc), rc, 0 );
192 if( !be_issuffix( be, &ptr )) {
193 buf[0] = DN_SUBTREE_PREFIX;
194 rc = db->del( db, txn, &key, 0 );
197 LDAP_LOG ( INDEX, ERR,
198 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
201 Debug( LDAP_DEBUG_ANY,
202 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
208 dnParent( &ptr, &pdn );
210 key.size = pdn.bv_len + 2;
212 pdn.bv_val[-1] = DN_ONE_PREFIX;
213 key.data = pdn.bv_val - 1;
216 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
220 LDAP_LOG ( INDEX, ERR,
221 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
224 Debug( LDAP_DEBUG_ANY,
225 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
232 while( !be_issuffix( be, &ptr )) {
233 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
235 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
238 LDAP_LOG ( INDEX, ERR,
239 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
242 Debug( LDAP_DEBUG_ANY,
243 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
248 dnParent( &ptr, &pdn );
250 key.size = pdn.bv_len + 2;
252 key.data = pdn.bv_val - 1;
259 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
261 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
276 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
277 DB *db = bdb->bi_dn2id->bdi_db;
280 LDAP_LOG ( INDEX, ARGS, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
282 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
287 *id = bdb_cache_find_entry_ndn2id(be, &bdb->bi_cache, dn);
293 key.size = dn->bv_len + 2;
294 key.data = ch_malloc( key.size );
295 ((char *)key.data)[0] = DN_BASE_PREFIX;
296 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
301 data.ulen = sizeof(ID);
302 data.flags = DB_DBT_USERMEM;
305 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags | flags);
309 LDAP_LOG ( INDEX, ERR, "<= bdb_dn2id: get failed %s (%d)\n",
310 db_strerror(rc), rc, 0 );
312 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n",
313 db_strerror( rc ), rc, 0 );
317 LDAP_LOG ( INDEX, RESULTS,
318 "<= bdb_dn2id: got id=0x%08lx\n", *id, 0, 0 );
320 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: got id=0x%08lx\n",
340 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
341 DB *db = bdb->bi_dn2id->bdi_db;
347 LDAP_LOG ( INDEX, ARGS,
348 "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 );
350 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 );
354 key.size = in->bv_len + 2;
355 buf = ch_malloc( key.size );
358 dn.bv_len = key.size - 2;
359 AC_MEMCPY( dn.bv_val, in->bv_val, key.size - 1 );
364 data.ulen = sizeof(ID);
365 data.flags = DB_DBT_USERMEM;
368 dn.bv_val[-1] = DN_BASE_PREFIX;
373 cached_id = bdb_cache_find_entry_ndn2id(be, &bdb->bi_cache, &dn);
375 if (cached_id != NOID) {
378 if ( dn.bv_val != buf+1 ) {
384 rc = db->get(db, txn, &key, &data, bdb->bi_db_opflags | flags );
387 if( rc == DB_NOTFOUND ) {
390 if ( ! be_issuffix( be, &dn ) ) {
391 dnParent( &dn, &pdn );
394 LDAP_LOG ( INDEX, DETAIL1,
395 "<= bdb_dn2id_matched: no match\n", 0, 0, 0 );
397 Debug( LDAP_DEBUG_TRACE,
398 "<= bdb_dn2id_matched: no match\n",
404 key.size = pdn.bv_len + 2;
406 key.data = pdn.bv_val - 1;
408 } else if ( rc == 0 ) {
409 if( data.size != sizeof( ID ) ) {
411 LDAP_LOG ( INDEX, DETAIL1,
412 "<= bdb_dn2id_matched: get size mismatch:"
413 "expected %ld, got %ld\n",
414 (long) sizeof(ID), (long) data.size, 0 );
416 Debug( LDAP_DEBUG_ANY,
417 "<= bdb_dn2id_matched: get size mismatch: "
418 "expected %ld, got %ld\n",
419 (long) sizeof(ID), (long) data.size, 0 );
423 if( dn.bv_val != buf+1 ) {
428 LDAP_LOG ( INDEX, DETAIL1,
429 "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n",
430 (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val );
432 Debug( LDAP_DEBUG_TRACE,
433 "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n",
434 (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val );
440 LDAP_LOG ( INDEX, ERR,
441 "<= bdb_dn2id_matched: get failed: %s (%d)\n",
442 db_strerror(rc), rc, 0 );
444 Debug( LDAP_DEBUG_ANY,
445 "<= bdb_dn2id_matched: get failed: %s (%d)\n",
446 db_strerror(rc), rc, 0 );
465 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
466 DB *db = bdb->bi_dn2id->bdi_db;
470 LDAP_LOG ( INDEX, ARGS,
471 "=> bdb_dn2id_children( %s )\n", dn->bv_val, 0, 0 );
473 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_children( %s )\n",
478 key.size = dn->bv_len + 2;
479 key.data = ch_malloc( key.size );
480 ((char *)key.data)[0] = DN_ONE_PREFIX;
481 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
483 /* we actually could do a empty get... */
486 data.ulen = sizeof(id);
487 data.flags = DB_DBT_USERMEM;
489 data.dlen = sizeof(id);
491 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags | flags );
495 LDAP_LOG ( INDEX, DETAIL1,
496 "<= bdb_dn2id_children( %s ): %schildren (%d)\n",
497 dn->bv_val, rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
498 db_strerror(rc)), rc );
500 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %schildren (%d)\n",
502 rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
503 db_strerror(rc) ), rc );
518 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
519 DB *db = bdb->bi_dn2id->bdi_db;
522 LDAP_LOG ( INDEX, ARGS,
523 "=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val, 0, 0 );
525 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 );
528 if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn))
530 BDB_IDL_ALL(bdb, ids);
535 key.size = dn->bv_len + 2;
537 key.flags = DB_DBT_USERMEM;
538 key.data = ch_malloc( key.size );
539 ((char *)key.data)[0] = prefix;
540 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
542 rc = bdb_idl_fetch_key( be, db, NULL, &key, ids );
546 LDAP_LOG ( INDEX, ERR,
547 "<= bdb_dn2ididl: get failed: %s (%d)\n", db_strerror(rc), rc, 0 );
549 Debug( LDAP_DEBUG_TRACE,
550 "<= bdb_dn2idl: get failed: %s (%d)\n",
551 db_strerror( rc ), rc, 0 );
556 LDAP_LOG ( INDEX, RESULTS,
557 "<= bdb_dn2ididl: id=%ld first=%ld last=%ld\n",
558 (long) ids[0], (long) BDB_IDL_FIRST( ids ),
559 (long) BDB_IDL_LAST( ids ) );
561 Debug( LDAP_DEBUG_TRACE,
562 "<= bdb_dn2idl: id=%ld first=%ld last=%ld\n",
564 (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) );
573 /* Experimental management routines for a hierarchically structured backend.
575 * Unsupported! Use at your own risk!
577 * Instead of a dn2id database, we use an id2parent database. Each entry in
578 * this database is a struct diskNode, containing the ID of the node's parent
579 * and the RDN of the node.
581 typedef struct diskNode {
587 /* In bdb_db_open() we call bdb_build_tree() which reads the entire id2parent
588 * database into memory (into an AVL tree). Next we iterate through each node
589 * of this tree, connecting each child to its parent. The nodes in this AVL
590 * tree are a struct idNode. The immediate (Onelevel) children of a node are
591 * referenced in the i_kids AVL tree. With this arrangement, there is no need
592 * to maintain the DN_ONE_PREFIX or DN_SUBTREE_PREFIX database keys. Note that
593 * the DN of an entry is constructed by walking up the list of i_parent
594 * pointers, so no full DN is stored on disk anywhere. This makes modrdn
595 * extremely efficient, even when operating on a populated subtree.
597 * The idNode tree is searched directly from the root when performing id to
598 * entry lookups. The tree is traversed using the i_kids subtrees when
599 * performing dn to id lookups.
601 typedef struct idNode {
603 struct idNode *i_parent;
606 ldap_pvt_thread_rdwr_t i_kids_rdwr;
610 /* The main AVL tree is sorted in ID order. The i_kids AVL trees are
611 * sorted in lexical order. These are the various helper routines used
612 * for the searches and sorts.
629 return ber_bvcmp(nrdn, &n->i_rdn->nrdn);
638 return a->i_id - b->i_id;
647 /* should be slightly better without ordering drawbacks */
648 return ber_bvcmp(&a->i_rdn->nrdn, &b->i_rdn->nrdn);
651 idNode * bdb_find_id_node(
656 return avl_find(tree, (const void *)id, (AVL_CMP)node_find_cmp);
659 idNode * bdb_find_rdn_node(
664 return avl_find(tree, (const void *)nrdn, (AVL_CMP)node_frdn_cmp);
667 /* This function links a node into its parent's i_kids tree. */
675 if (a->i_rdn->parent == 0)
677 a->i_parent = bdb_find_id_node(a->i_rdn->parent, tree);
680 ldap_pvt_thread_rdwr_wlock(&a->i_parent->i_kids_rdwr);
681 rc = avl_insert( &a->i_parent->i_kids, (caddr_t) a,
682 (AVL_CMP)node_rdn_cmp, (AVL_DUP) avl_dup_error );
683 ldap_pvt_thread_rdwr_wunlock(&a->i_parent->i_kids_rdwr);
687 /* This function adds a node into the main AVL tree */
688 idNode *bdb_add_node(
696 node = (idNode *)ch_malloc(sizeof(idNode));
698 node->i_parent = NULL;
700 node->i_rdn = (diskNode *)d;
701 node->i_rdn->rdn.bv_val += (long)d;
702 node->i_rdn->nrdn.bv_val += (long)d;
703 ldap_pvt_thread_rdwr_init(&node->i_kids_rdwr);
704 avl_insert( &bdb->bi_tree, (caddr_t) node,
705 (AVL_CMP)node_add_cmp, (AVL_DUP) avl_dup_error );
707 bdb->bi_troot = node;
711 /* This function initializes the trees at startup time. */
716 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
725 rc = bdb->bi_id2parent->bdi_db->cursor(
726 bdb->bi_id2parent->bdi_db, NULL, &cursor,
727 bdb->bi_db_opflags );
734 key.data = (char *)&id;
735 key.ulen = sizeof( id );
736 key.flags = DB_DBT_USERMEM;
737 data.flags = DB_DBT_MALLOC;
739 while (cursor->c_get( cursor, &key, &data, DB_NEXT ) == 0) {
740 bdb_add_node( id, data.data, bdb );
742 cursor->c_close( cursor );
744 rc = avl_apply(bdb->bi_tree, (AVL_APPLY)bdb_insert_kid, bdb->bi_tree,
750 /* This function constructs a full DN for a given id. We really should
751 * be passing idNodes directly, to save some effort...
759 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
764 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
765 o = bdb_find_id_node(id, bdb->bi_tree);
766 rlen = be->be_suffix[0].bv_len + 1;
767 nrlen = be->be_nsuffix[0].bv_len + 1;
768 for (n = o; n && n->i_parent; n=n->i_parent) {
769 rlen += n->i_rdn->rdn.bv_len + 1;
770 nrlen += n->i_rdn->nrdn.bv_len + 1;
772 e->e_name.bv_len = rlen - 1;
773 e->e_nname.bv_len = nrlen - 1;
774 e->e_name.bv_val = ch_malloc(rlen + nrlen);
775 e->e_nname.bv_val = e->e_name.bv_val + rlen;
776 ptr = e->e_name.bv_val;
777 nptr = e->e_nname.bv_val;
778 for (n = o; n && n->i_parent; n=n->i_parent) {
779 ptr = lutil_strcopy(ptr, n->i_rdn->rdn.bv_val);
781 nptr = lutil_strcopy(nptr, n->i_rdn->nrdn.bv_val);
784 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
786 strcpy(ptr, be->be_suffix[0].bv_val);
787 strcpy(nptr, be->be_nsuffix[0].bv_val);
799 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
802 DB *db = bdb->bi_id2parent->bdi_db;
806 nrlen = dn_rdnlen( be, &e->e_nname );
808 rlen = dn_rdnlen( be, &e->e_name );
813 d = ch_malloc(sizeof(diskNode) + rlen + nrlen + 2);
814 d->rdn.bv_len = rlen;
815 d->nrdn.bv_len = nrlen;
816 d->rdn.bv_val = (char *)(d+1);
817 d->nrdn.bv_val = d->rdn.bv_val + rlen + 1;
818 strncpy(d->rdn.bv_val, e->e_dn, rlen);
819 d->rdn.bv_val[rlen] = '\0';
820 strncpy(d->nrdn.bv_val, e->e_ndn, nrlen);
821 d->nrdn.bv_val[nrlen] = '\0';
822 d->rdn.bv_val -= (long)d;
823 d->nrdn.bv_val -= (long)d;
826 bdb_dn2id(be, txn, pdn, &d->parent, 0);
834 key.size = sizeof(ID);
835 key.flags = DB_DBT_USERMEM;
838 data.size = sizeof(diskNode) + rlen + nrlen + 2;
839 data.flags = DB_DBT_USERMEM;
841 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
844 ldap_pvt_thread_rdwr_wlock(&bdb->bi_tree_rdwr);
845 n = bdb_add_node( e->e_id, data.data, bdb);
846 ldap_pvt_thread_rdwr_wunlock(&bdb->bi_tree_rdwr);
849 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
850 bdb_insert_kid(n, bdb->bi_tree);
851 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
866 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
869 DB *db = bdb->bi_id2parent->bdi_db;
873 key.size = sizeof(e->e_id);
876 rc = db->del( db, txn, &key, 0);
878 ldap_pvt_thread_rdwr_wlock(&bdb->bi_tree_rdwr);
879 n = avl_delete(&bdb->bi_tree, (void *)e->e_id, (AVL_CMP)node_find_cmp);
882 ldap_pvt_thread_rdwr_wlock(&n->i_parent->i_kids_rdwr);
883 avl_delete(&n->i_parent->i_kids, &n->i_rdn->nrdn,
884 (AVL_CMP)node_frdn_cmp);
885 ldap_pvt_thread_rdwr_wunlock(&n->i_parent->i_kids_rdwr);
888 ldap_pvt_thread_rdwr_destroy(&n->i_kids_rdwr);
892 bdb->bi_troot = NULL;
893 ldap_pvt_thread_rdwr_wunlock(&bdb->bi_tree_rdwr);
907 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
916 if (be_issuffix(be, in)) {
921 p1 = in->bv_val + in->bv_len - be->be_nsuffix[0].bv_len - 1;
924 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
926 for (p2 = p1-1; (p2 >= in->bv_val) && !DN_SEPARATOR(*p2); p2--);
928 rdn.bv_len = p1-rdn.bv_val;
931 ldap_pvt_thread_rdwr_rlock(&p->i_kids_rdwr);
932 n = bdb_find_rdn_node(&rdn, p->i_kids);
933 ldap_pvt_thread_rdwr_runlock(&p->i_kids_rdwr);
934 if (!n || p2 < in->bv_val) break;
937 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
944 return n ? 0 : DB_NOTFOUND;
955 return bdb_dn2id_matched(be, txn, dn, id, NULL, flags);
966 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
970 rc = bdb_dn2id(be, txn, dn, &id, flags);
974 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
975 n = bdb_find_id_node(id, bdb->bi_tree);
976 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
984 /* Since we don't store IDLs for onelevel or subtree, we have to construct
985 * them on the fly... Perhaps the i_kids tree ought to just be an IDL?
993 return bdb_idl_insert(ids, n->i_id);
1004 rc = bdb_idl_insert(ids, n->i_id);
1006 ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
1007 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
1009 ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
1021 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
1026 if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn)) {
1027 BDB_IDL_ALL(bdb, ids);
1031 rc = bdb_dn2id(be, NULL, dn, &id, 0);
1034 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
1035 n = bdb_find_id_node(id, bdb->bi_tree);
1036 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
1039 ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
1040 if (prefix == DN_ONE_PREFIX) {
1041 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_one, ids, -1,
1044 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
1047 ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
1050 #endif /* BDB_HIER */