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>
24 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
25 DB *db = bdb->bi_dn2id->bdi_db;
29 struct berval ptr, pdn;
32 LDAP_LOG ( INDEX, ARGS, "bdb_dn2id_add( \"%s\", 0x%08lx )\n",
33 e->e_ndn, (long) e->e_id, 0 );
35 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n",
36 e->e_ndn, (long) e->e_id, 0 );
38 assert( e->e_id != NOID );
41 key.size = e->e_nname.bv_len + 2;
43 key.flags = DB_DBT_USERMEM;
44 buf = ch_malloc( key.size );
46 buf[0] = DN_BASE_PREFIX;
48 ptr.bv_len = e->e_nname.bv_len;
49 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
50 ptr.bv_val[ptr.bv_len] = '\0';
53 data.data = (char *) &e->e_id;
54 data.size = sizeof( e->e_id );
56 /* store it -- don't override */
57 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
60 LDAP_LOG ( INDEX, ERR, "bdb_dn2id_add: put failed: %s %d\n",
61 db_strerror(rc), rc, 0 );
63 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n",
64 db_strerror(rc), rc, 0 );
69 if( !be_issuffix( be, &ptr )) {
70 buf[0] = DN_SUBTREE_PREFIX;
71 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
74 LDAP_LOG ( INDEX, ERR,
75 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
78 Debug( LDAP_DEBUG_ANY,
79 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
85 dnParent( &ptr, &pdn );
87 key.size = pdn.bv_len + 2;
89 pdn.bv_val[-1] = DN_ONE_PREFIX;
90 key.data = pdn.bv_val-1;
93 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
97 LDAP_LOG ( INDEX, ERR,
98 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
101 Debug( LDAP_DEBUG_ANY,
102 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
109 while( !be_issuffix( be, &ptr )) {
110 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
112 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
116 LDAP_LOG ( INDEX, ERR,
117 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
120 Debug( LDAP_DEBUG_ANY,
121 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
126 dnParent( &ptr, &pdn );
128 key.size = pdn.bv_len + 2;
130 key.data = pdn.bv_val - 1;
137 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
139 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
151 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
152 DB *db = bdb->bi_dn2id->bdi_db;
156 struct berval pdn, ptr;
159 LDAP_LOG ( INDEX, ARGS,
160 "=> bdb_dn2id_delete ( \"%s\", 0x%08lx )\n", e->e_ndn, e->e_id, 0);
162 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", 0x%08lx )\n",
163 e->e_ndn, e->e_id, 0 );
167 key.size = e->e_nname.bv_len + 2;
168 buf = ch_malloc( key.size );
170 key.flags = DB_DBT_USERMEM;
171 buf[0] = DN_BASE_PREFIX;
173 ptr.bv_len = e->e_nname.bv_len;
174 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
175 ptr.bv_val[ptr.bv_len] = '\0';
178 rc = db->del( db, txn, &key, 0 );
181 LDAP_LOG ( INDEX, ERR,
182 "=> bdb_dn2id_delete: delete failed: %s %d\n",
183 db_strerror(rc), rc, 0 );
185 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n",
186 db_strerror(rc), rc, 0 );
191 if( !be_issuffix( be, &ptr )) {
192 buf[0] = DN_SUBTREE_PREFIX;
193 rc = db->del( db, txn, &key, 0 );
196 LDAP_LOG ( INDEX, ERR,
197 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
200 Debug( LDAP_DEBUG_ANY,
201 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
207 dnParent( &ptr, &pdn );
209 key.size = pdn.bv_len + 2;
211 pdn.bv_val[-1] = DN_ONE_PREFIX;
212 key.data = pdn.bv_val - 1;
215 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
219 LDAP_LOG ( INDEX, ERR,
220 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
223 Debug( LDAP_DEBUG_ANY,
224 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
231 while( !be_issuffix( be, &ptr )) {
232 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
234 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
237 LDAP_LOG ( INDEX, ERR,
238 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
241 Debug( LDAP_DEBUG_ANY,
242 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
247 dnParent( &ptr, &pdn );
249 key.size = pdn.bv_len + 2;
251 key.data = pdn.bv_val - 1;
258 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
260 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
275 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
276 DB *db = bdb->bi_dn2id->bdi_db;
279 LDAP_LOG ( INDEX, ARGS, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
281 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
286 *id = bdb_cache_find_entry_ndn2id(be, &bdb->bi_cache, dn);
292 key.size = dn->bv_len + 2;
293 key.data = ch_malloc( key.size );
294 ((char *)key.data)[0] = DN_BASE_PREFIX;
295 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
300 data.ulen = sizeof(ID);
301 data.flags = DB_DBT_USERMEM;
304 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags | flags);
308 LDAP_LOG ( INDEX, ERR, "<= bdb_dn2id: get failed %s (%d)\n",
309 db_strerror(rc), rc, 0 );
311 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n",
312 db_strerror( rc ), rc, 0 );
316 LDAP_LOG ( INDEX, RESULTS,
317 "<= bdb_dn2id: got id=0x%08lx\n", *id, 0, 0 );
319 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: got id=0x%08lx\n",
339 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
340 DB *db = bdb->bi_dn2id->bdi_db;
346 LDAP_LOG ( INDEX, ARGS,
347 "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 );
349 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_matched( \"%s\" )\n", in->bv_val, 0, 0 );
353 key.size = in->bv_len + 2;
354 buf = ch_malloc( key.size );
357 dn.bv_len = key.size - 2;
358 AC_MEMCPY( dn.bv_val, in->bv_val, key.size - 1 );
363 data.ulen = sizeof(ID);
364 data.flags = DB_DBT_USERMEM;
367 dn.bv_val[-1] = DN_BASE_PREFIX;
372 cached_id = bdb_cache_find_entry_ndn2id(be, &bdb->bi_cache, &dn);
374 if (cached_id != NOID) {
377 if ( dn.bv_val != buf+1 ) {
383 rc = db->get(db, txn, &key, &data, bdb->bi_db_opflags | flags );
386 if( rc == DB_NOTFOUND ) {
389 if ( ! be_issuffix( be, &dn ) ) {
390 dnParent( &dn, &pdn );
393 LDAP_LOG ( INDEX, DETAIL1,
394 "<= bdb_dn2id_matched: no match\n", 0, 0, 0 );
396 Debug( LDAP_DEBUG_TRACE,
397 "<= bdb_dn2id_matched: no match\n",
403 key.size = pdn.bv_len + 2;
405 key.data = pdn.bv_val - 1;
407 } else if ( rc == 0 ) {
408 if( data.size != sizeof( ID ) ) {
410 LDAP_LOG ( INDEX, DETAIL1,
411 "<= bdb_dn2id_matched: get size mismatch:"
412 "expected %ld, got %ld\n",
413 (long) sizeof(ID), (long) data.size, 0 );
415 Debug( LDAP_DEBUG_ANY,
416 "<= bdb_dn2id_matched: get size mismatch: "
417 "expected %ld, got %ld\n",
418 (long) sizeof(ID), (long) data.size, 0 );
422 if( dn.bv_val != buf+1 ) {
427 LDAP_LOG ( INDEX, DETAIL1,
428 "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n",
429 (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val );
431 Debug( LDAP_DEBUG_TRACE,
432 "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n",
433 (long) *id, *id2 == 0 ? "entry" : "matched", dn.bv_val );
439 LDAP_LOG ( INDEX, ERR,
440 "<= bdb_dn2id_matched: get failed: %s (%d)\n",
441 db_strerror(rc), rc, 0 );
443 Debug( LDAP_DEBUG_ANY,
444 "<= bdb_dn2id_matched: get failed: %s (%d)\n",
445 db_strerror(rc), rc, 0 );
464 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
465 DB *db = bdb->bi_dn2id->bdi_db;
469 LDAP_LOG ( INDEX, ARGS,
470 "=> bdb_dn2id_children( %s )\n", dn->bv_val, 0, 0 );
472 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_children( %s )\n",
477 key.size = dn->bv_len + 2;
478 key.data = ch_malloc( key.size );
479 ((char *)key.data)[0] = DN_ONE_PREFIX;
480 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
482 /* we actually could do a empty get... */
485 data.ulen = sizeof(id);
486 data.flags = DB_DBT_USERMEM;
488 data.dlen = sizeof(id);
490 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags | flags );
494 LDAP_LOG ( INDEX, DETAIL1,
495 "<= bdb_dn2id_children( %s ): %schildren (%d)\n",
496 dn->bv_val, rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
497 db_strerror(rc)), rc );
499 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %schildren (%d)\n",
501 rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
502 db_strerror(rc) ), rc );
517 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
518 DB *db = bdb->bi_dn2id->bdi_db;
521 LDAP_LOG ( INDEX, ARGS,
522 "=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val, 0, 0 );
524 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 );
527 if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn))
529 BDB_IDL_ALL(bdb, ids);
534 key.size = dn->bv_len + 2;
536 key.flags = DB_DBT_USERMEM;
537 key.data = ch_malloc( key.size );
538 ((char *)key.data)[0] = prefix;
539 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
541 rc = bdb_idl_fetch_key( be, db, NULL, &key, ids );
545 LDAP_LOG ( INDEX, ERR,
546 "<= bdb_dn2ididl: get failed: %s (%d)\n", db_strerror(rc), rc, 0 );
548 Debug( LDAP_DEBUG_TRACE,
549 "<= bdb_dn2idl: get failed: %s (%d)\n",
550 db_strerror( rc ), rc, 0 );
555 LDAP_LOG ( INDEX, RESULTS,
556 "<= bdb_dn2ididl: id=%ld first=%ld last=%ld\n",
557 (long) ids[0], (long) BDB_IDL_FIRST( ids ),
558 (long) BDB_IDL_LAST( ids ) );
560 Debug( LDAP_DEBUG_TRACE,
561 "<= bdb_dn2idl: id=%ld first=%ld last=%ld\n",
563 (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) );
572 /* Experimental management routines for a hierarchically structured backend.
574 * Unsupported! Use at your own risk!
576 * Instead of a dn2id database, we use an id2parent database. Each entry in
577 * this database is a struct diskNode, containing the ID of the node's parent
578 * and the RDN of the node.
580 typedef struct diskNode {
586 /* In bdb_db_open() we call bdb_build_tree() which reads the entire id2parent
587 * database into memory (into an AVL tree). Next we iterate through each node
588 * of this tree, connecting each child to its parent. The nodes in this AVL
589 * tree are a struct idNode. The immediate (Onelevel) children of a node are
590 * referenced in the i_kids AVL tree. With this arrangement, there is no need
591 * to maintain the DN_ONE_PREFIX or DN_SUBTREE_PREFIX database keys. Note that
592 * the DN of an entry is constructed by walking up the list of i_parent
593 * pointers, so no full DN is stored on disk anywhere. This makes modrdn
594 * extremely efficient, even when operating on a populated subtree.
596 * The idNode tree is searched directly from the root when performing id to
597 * entry lookups. The tree is traversed using the i_kids subtrees when
598 * performing dn to id lookups.
600 typedef struct idNode {
602 struct idNode *i_parent;
605 ldap_pvt_thread_rdwr_t i_kids_rdwr;
609 /* The main AVL tree is sorted in ID order. The i_kids AVL trees are
610 * sorted in lexical order. These are the various helper routines used
611 * for the searches and sorts.
628 return strcmp(nrdn, n->i_rdn->nrdn.bv_val);
637 return a->i_id - b->i_id;
647 return strcmp(a->i_rdn->nrdn.bv_val, b->i_rdn->nrdn.bv_val);
649 /* should be slightly better without ordering drawbacks */
650 return ber_bvcmp(&a->i_rdn->nrdn, &b->i_rdn->nrdn);
653 idNode * bdb_find_id_node(
658 return avl_find(tree, (const void *)id, (AVL_CMP)node_find_cmp);
661 idNode * bdb_find_rdn_node(
666 return avl_find(tree, (const void *)nrdn, (AVL_CMP)node_frdn_cmp);
669 /* This function links a node into its parent's i_kids tree. */
677 if (a->i_rdn->parent == 0)
679 a->i_parent = bdb_find_id_node(a->i_rdn->parent, tree);
682 ldap_pvt_thread_rdwr_wlock(&a->i_parent->i_kids_rdwr);
683 rc = avl_insert( &a->i_parent->i_kids, (caddr_t) a,
684 (AVL_CMP)node_rdn_cmp, (AVL_DUP) avl_dup_error );
685 ldap_pvt_thread_rdwr_wunlock(&a->i_parent->i_kids_rdwr);
689 /* This function adds a node into the main AVL tree */
690 idNode *bdb_add_node(
698 node = (idNode *)ch_malloc(sizeof(idNode));
700 node->i_parent = NULL;
702 node->i_rdn = (diskNode *)d;
703 node->i_rdn->rdn.bv_val += (long)d;
704 node->i_rdn->nrdn.bv_val += (long)d;
705 ldap_pvt_thread_rdwr_init(&node->i_kids_rdwr);
706 avl_insert( &bdb->bi_tree, (caddr_t) node,
707 (AVL_CMP)node_add_cmp, (AVL_DUP) avl_dup_error );
709 bdb->bi_troot = node;
713 /* This function initializes the trees at startup time. */
718 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
728 rc = bdb->bi_id2parent->bdi_db->cursor(
729 bdb->bi_id2parent->bdi_db, NULL, &cursor,
730 bdb->bi_db_opflags );
735 /* When be_suffix is turned into struct berval or LDAPDN
736 * life will get a lot easier... Since no DNs live on disk, we
737 * need to operate on the be_suffix to fully qualify our DNs.
738 * We need to know how many components are in the suffix DN,
739 * so we can tell where the suffix ends and our nodes begin.
741 * Note that this code always uses be_suffix[0], so defining
742 * multiple suffixes for a single backend won't work!
744 rdns = ldap_explode_dn(be->be_nsuffix[0].bv_val, 0);
745 for (i=0; rdns[i]; i++);
751 key.data = (char *)&id;
752 key.ulen = sizeof( id );
753 key.flags = DB_DBT_USERMEM;
754 data.flags = DB_DBT_MALLOC;
756 while (cursor->c_get( cursor, &key, &data, DB_NEXT ) == 0) {
757 bdb_add_node( id, data.data, bdb );
759 cursor->c_close( cursor );
761 rc = avl_apply(bdb->bi_tree, (AVL_APPLY)bdb_insert_kid, bdb->bi_tree,
767 /* This function constructs a full DN for a given id. We really should
768 * be passing idNodes directly, to save some effort...
776 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
781 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
782 o = bdb_find_id_node(id, bdb->bi_tree);
783 rlen = be->be_suffix[0].bv_len + 1;
784 nrlen = be->be_nsuffix[0].bv_len + 1;
785 for (n = o; n && n->i_parent; n=n->i_parent) {
786 rlen += n->i_rdn->rdn.bv_len + 1;
787 nrlen += n->i_rdn->nrdn.bv_len + 1;
789 e->e_name.bv_len = rlen - 1;
790 e->e_nname.bv_len = nrlen - 1;
791 e->e_name.bv_val = ch_malloc(rlen + nrlen);
792 e->e_nname.bv_val = e->e_name.bv_val + rlen;
793 ptr = e->e_name.bv_val;
794 nptr = e->e_nname.bv_val;
795 for (n = o; n && n->i_parent; n=n->i_parent) {
796 ptr = lutil_strcopy(ptr, n->i_rdn->rdn.bv_val);
798 nptr = lutil_strcopy(nptr, n->i_rdn->nrdn.bv_val);
801 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
803 strcpy(ptr, be->be_suffix[0].bv_val);
804 strcpy(nptr, be->be_nsuffix[0].bv_val);
816 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
819 DB *db = bdb->bi_id2parent->bdi_db;
823 nrlen = dn_rdnlen( be, &e->e_nname );
825 rlen = dn_rdnlen( be, &e->e_name );
830 d = ch_malloc(sizeof(diskNode) + rlen + nrlen + 2);
831 d->rdn.bv_len = rlen;
832 d->nrdn.bv_len = nrlen;
833 d->rdn.bv_val = (char *)(d+1);
834 d->nrdn.bv_val = d->rdn.bv_val + rlen + 1;
835 strncpy(d->rdn.bv_val, e->e_dn, rlen);
836 d->rdn.bv_val[rlen] = '\0';
837 strncpy(d->nrdn.bv_val, e->e_ndn, nrlen);
838 d->nrdn.bv_val[nrlen] = '\0';
839 d->rdn.bv_val -= (long)d;
840 d->nrdn.bv_val -= (long)d;
843 bdb_dn2id(be, txn, pdn, &d->parent);
851 key.size = sizeof(ID);
852 key.flags = DB_DBT_USERMEM;
855 data.size = sizeof(diskNode) + rlen + nrlen + 2;
856 data.flags = DB_DBT_USERMEM;
858 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
861 ldap_pvt_thread_rdwr_wlock(&bdb->bi_tree_rdwr);
862 n = bdb_add_node( e->e_id, data.data, bdb);
863 ldap_pvt_thread_rdwr_wunlock(&bdb->bi_tree_rdwr);
866 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
867 bdb_insert_kid(n, bdb->bi_tree);
868 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
883 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
886 DB *db = bdb->bi_id2parent->bdi_db;
890 key.size = sizeof(e->e_id);
893 rc = db->del( db, txn, &key, 0);
895 ldap_pvt_thread_rdwr_wlock(&bdb->bi_tree_rdwr);
896 n = avl_delete(&bdb->bi_tree, (void *)e->e_id, (AVL_CMP)node_find_cmp);
899 ldap_pvt_thread_rdwr_wlock(&n->i_parent->i_kids_rdwr);
900 avl_delete(&n->i_parent->i_kids, n->i_rdn->nrdn.bv_val,
901 (AVL_CMP)node_frdn_cmp);
902 ldap_pvt_thread_rdwr_wunlock(&n->i_parent->i_kids_rdwr);
905 ldap_pvt_thread_rdwr_destroy(&n->i_kids_rdwr);
909 bdb->bi_troot = NULL;
910 ldap_pvt_thread_rdwr_wunlock(&bdb->bi_tree_rdwr);
923 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
932 if (be_issuffix(be, in)) {
937 rdns = ldap_explode_dn(in->bv_val, 0);
938 for (i=0; rdns[i]; i++);
945 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
946 for (--i; i>=0; i--) {
947 ldap_pvt_thread_rdwr_rlock(&p->i_kids_rdwr);
948 n = bdb_find_rdn_node(rdns[i], p->i_kids);
949 ldap_pvt_thread_rdwr_runlock(&p->i_kids_rdwr);
953 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
961 return n ? 0 : DB_NOTFOUND;
971 return bdb_dn2id_matched(be, txn, dn, id, NULL);
981 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
985 rc = bdb_dn2id(be, txn, dn, &id);
989 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
990 n = bdb_find_id_node(id, bdb->bi_tree);
991 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
999 /* Since we don't store IDLs for onelevel or subtree, we have to construct
1000 * them on the fly... Perhaps the i_kids tree ought to just be an IDL?
1008 return bdb_idl_insert(ids, n->i_id);
1019 rc = bdb_idl_insert(ids, n->i_id);
1021 ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
1022 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
1024 ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
1036 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
1041 if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn)) {
1042 BDB_IDL_ALL(bdb, ids);
1046 rc = bdb_dn2id(be, NULL, dn, &id);
1049 ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr);
1050 n = bdb_find_id_node(id, bdb->bi_tree);
1051 ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
1054 ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
1055 if (prefix == DN_ONE_PREFIX) {
1056 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_one, ids, -1,
1059 rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1,
1062 ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
1065 #endif /* BDB_HIER */