1 /* dn2id.c - routines to deal with the dn2id index */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #include <ac/string.h>
26 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
27 DB *db = bdb->bi_dn2id->bdi_db;
31 struct berval ptr, pdn;
34 LDAP_LOG ( INDEX, ARGS, "bdb_dn2id_add( \"%s\", 0x%08lx )\n",
35 e->e_ndn, (long) e->e_id, 0 );
37 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_add( \"%s\", 0x%08lx )\n",
38 e->e_ndn, (long) e->e_id, 0 );
40 assert( e->e_id != NOID );
43 key.size = e->e_nname.bv_len + 2;
45 key.flags = DB_DBT_USERMEM;
46 buf = sl_malloc( key.size, ctx );
48 buf[0] = DN_BASE_PREFIX;
50 ptr.bv_len = e->e_nname.bv_len;
51 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
52 ptr.bv_val[ptr.bv_len] = '\0';
55 data.data = (char *) &e->e_id;
56 data.size = sizeof( e->e_id );
58 /* store it -- don't override */
59 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
62 LDAP_LOG ( INDEX, ERR, "bdb_dn2id_add: put failed: %s %d\n",
63 db_strerror(rc), rc, 0 );
65 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_add: put failed: %s %d\n",
66 db_strerror(rc), rc, 0 );
71 #ifndef BDB_MULTIPLE_SUFFIXES
72 if( !be_issuffix( be, &ptr )) {
74 buf[0] = DN_SUBTREE_PREFIX;
75 rc = db->put( db, txn, &key, &data, DB_NOOVERWRITE );
78 LDAP_LOG ( INDEX, ERR,
79 "=> bdb_dn2id_add: subtree (%s) put failed: %d\n",
82 Debug( LDAP_DEBUG_ANY,
83 "=> bdb_dn2id_add: subtree (%s) put failed: %d\n",
89 #ifdef BDB_MULTIPLE_SUFFIXES
90 if( !be_issuffix( be, &ptr )) {
92 dnParent( &ptr, &pdn );
94 key.size = pdn.bv_len + 2;
96 pdn.bv_val[-1] = DN_ONE_PREFIX;
97 key.data = pdn.bv_val-1;
100 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
104 LDAP_LOG ( INDEX, ERR,
105 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
108 Debug( LDAP_DEBUG_ANY,
109 "=> bdb_dn2id_add: parent (%s) insert failed: %d\n",
114 #ifndef BDB_MULTIPLE_SUFFIXES
117 while( !be_issuffix( be, &ptr )) {
121 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
123 rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id );
127 LDAP_LOG ( INDEX, ERR,
128 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
131 Debug( LDAP_DEBUG_ANY,
132 "=> bdb_dn2id_add: subtree (%s) insert failed: %d\n",
137 #ifdef BDB_MULTIPLE_SUFFIXES
138 if( be_issuffix( be, &ptr )) break;
140 dnParent( &ptr, &pdn );
142 key.size = pdn.bv_len + 2;
144 key.data = pdn.bv_val - 1;
147 #ifdef BDB_MULTIPLE_SUFFIXES
154 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
156 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_add: %d\n", rc, 0, 0 );
169 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
170 DB *db = bdb->bi_dn2id->bdi_db;
174 struct berval pdn, ptr;
177 LDAP_LOG ( INDEX, ARGS,
178 "=> bdb_dn2id_delete ( \"%s\", 0x%08lx )\n", e->e_ndn, e->e_id, 0);
180 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_delete( \"%s\", 0x%08lx )\n",
181 e->e_ndn, e->e_id, 0 );
185 key.size = e->e_nname.bv_len + 2;
186 buf = sl_malloc( key.size, ctx );
188 key.flags = DB_DBT_USERMEM;
189 buf[0] = DN_BASE_PREFIX;
191 ptr.bv_len = e->e_nname.bv_len;
192 AC_MEMCPY( ptr.bv_val, e->e_nname.bv_val, e->e_nname.bv_len );
193 ptr.bv_val[ptr.bv_len] = '\0';
196 rc = db->del( db, txn, &key, 0 );
199 LDAP_LOG ( INDEX, ERR,
200 "=> bdb_dn2id_delete: delete failed: %s %d\n",
201 db_strerror(rc), rc, 0 );
203 Debug( LDAP_DEBUG_ANY, "=> bdb_dn2id_delete: delete failed: %s %d\n",
204 db_strerror(rc), rc, 0 );
209 #ifndef BDB_MULTIPLE_SUFFIXES
210 if( !be_issuffix( be, &ptr )) {
212 buf[0] = DN_SUBTREE_PREFIX;
213 rc = db->del( db, txn, &key, 0 );
216 LDAP_LOG ( INDEX, ERR,
217 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
220 Debug( LDAP_DEBUG_ANY,
221 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
227 #ifdef BDB_MULTIPLE_SUFFIXES
228 if( !be_issuffix( be, &ptr )) {
230 dnParent( &ptr, &pdn );
232 key.size = pdn.bv_len + 2;
234 pdn.bv_val[-1] = DN_ONE_PREFIX;
235 key.data = pdn.bv_val - 1;
238 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
242 LDAP_LOG ( INDEX, ERR,
243 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
246 Debug( LDAP_DEBUG_ANY,
247 "=> bdb_dn2id_delete: parent (%s) delete failed: %d\n",
252 #ifndef BDB_MULTIPLE_SUFFIXES
255 while( !be_issuffix( be, &ptr )) {
259 ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
261 rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id );
264 LDAP_LOG ( INDEX, ERR,
265 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
268 Debug( LDAP_DEBUG_ANY,
269 "=> bdb_dn2id_delete: subtree (%s) delete failed: %d\n",
274 #ifdef BDB_MULTIPLE_SUFFIXES
275 if( be_issuffix( be, &ptr )) break;
277 dnParent( &ptr, &pdn );
279 key.size = pdn.bv_len + 2;
281 key.data = pdn.bv_val - 1;
284 #ifdef BDB_MULTIPLE_SUFFIXES
291 LDAP_LOG ( INDEX, RESULTS, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
293 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_delete %d\n", rc, 0, 0 );
308 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
309 DB *db = bdb->bi_dn2id->bdi_db;
312 LDAP_LOG ( INDEX, ARGS, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
314 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
318 key.size = dn->bv_len + 2;
319 key.data = sl_malloc( key.size, ctx );
320 ((char *)key.data)[0] = DN_BASE_PREFIX;
321 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
325 data.data = &ei->bei_id;
326 data.ulen = sizeof(ID);
327 data.flags = DB_DBT_USERMEM;
330 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
334 LDAP_LOG ( INDEX, ERR, "<= bdb_dn2id: get failed %s (%d)\n",
335 db_strerror(rc), rc, 0 );
337 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: get failed: %s (%d)\n",
338 db_strerror( rc ), rc, 0 );
342 LDAP_LOG ( INDEX, RESULTS,
343 "<= bdb_dn2id: got id=0x%08lx\n", ei->bei_id, 0, 0 );
345 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id: got id=0x%08lx\n",
350 sl_free( key.data, ctx );
361 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
362 DB *db = bdb->bi_dn2id->bdi_db;
367 LDAP_LOG ( INDEX, ARGS,
368 "=> bdb_dn2id_children( %s )\n", e->e_nname.bv_val, 0, 0 );
370 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2id_children( %s )\n",
371 e->e_nname.bv_val, 0, 0 );
374 key.size = e->e_nname.bv_len + 2;
375 key.data = sl_malloc( key.size, op->o_tmpmemctx );
376 ((char *)key.data)[0] = DN_ONE_PREFIX;
377 AC_MEMCPY( &((char *)key.data)[1], e->e_nname.bv_val, key.size - 1 );
379 #ifdef SLAP_IDL_CACHE
380 if ( bdb->bi_idl_cache_size ) {
381 rc = bdb_idl_cache_get( bdb, db, &key, NULL );
382 if ( rc != LDAP_NO_SUCH_OBJECT ) {
383 sl_free( key.data, op->o_tmpmemctx );
388 /* we actually could do a empty get... */
391 data.ulen = sizeof(id);
392 data.flags = DB_DBT_USERMEM;
394 data.dlen = sizeof(id);
396 rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags );
397 sl_free( key.data, op->o_tmpmemctx );
400 LDAP_LOG ( INDEX, DETAIL1,
401 "<= bdb_dn2id_children( %s ): %s (%d)\n",
402 e->e_nname.bv_val, rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
403 db_strerror(rc)), rc );
405 Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %s (%d)\n",
407 rc == 0 ? "" : ( rc == DB_NOTFOUND ? "no " :
408 db_strerror(rc) ), rc );
425 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
426 DB *db = bdb->bi_dn2id->bdi_db;
429 LDAP_LOG ( INDEX, ARGS,
430 "=> bdb_dn2ididl( \"%s\" )\n", dn->bv_val, 0, 0 );
432 Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", dn->bv_val, 0, 0 );
435 #ifndef BDB_MULTIPLE_SUFFIXES
436 if (prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn))
438 BDB_IDL_ALL(bdb, ids);
444 key.size = dn->bv_len + 2;
446 key.flags = DB_DBT_USERMEM;
447 key.data = sl_malloc( key.size, ctx );
448 ((char *)key.data)[0] = prefix;
449 AC_MEMCPY( &((char *)key.data)[1], dn->bv_val, key.size - 1 );
451 rc = bdb_idl_fetch_key( be, db, NULL, &key, ids );
455 LDAP_LOG ( INDEX, ERR,
456 "<= bdb_dn2ididl: get failed: %s (%d)\n", db_strerror(rc), rc, 0 );
458 Debug( LDAP_DEBUG_TRACE,
459 "<= bdb_dn2idl: get failed: %s (%d)\n",
460 db_strerror( rc ), rc, 0 );
465 LDAP_LOG ( INDEX, RESULTS,
466 "<= bdb_dn2ididl: id=%ld first=%ld last=%ld\n",
467 (long) ids[0], (long) BDB_IDL_FIRST( ids ),
468 (long) BDB_IDL_LAST( ids ) );
470 Debug( LDAP_DEBUG_TRACE,
471 "<= bdb_dn2idl: id=%ld first=%ld last=%ld\n",
473 (long) BDB_IDL_FIRST( ids ), (long) BDB_IDL_LAST( ids ) );
477 sl_free( key.data, ctx );
482 /* Experimental management routines for a hierarchically structured database.
484 * Unsupported! Use at your own risk!
485 * -- Howard Chu, Symas Corp. 2003.
487 * Instead of a ldbm-style dn2id database, we use a hierarchical one. Each
488 * entry in this database is a struct diskNode, keyed by entryID and with
489 * the data containing the RDN and entryID of the node's children. We use
490 * a B-Tree with sorted duplicates to store all the children of a node under
491 * the same key. Also, the first item under the key contains the entry's own
492 * rdn and the ID of the node's parent, to allow bottom-up tree traversal as
493 * well as top-down. To keep this info first in the list, the nrdnlen is set
494 * to the negative of its value.
496 * The diskNode is a variable length structure. This definition is not
497 * directly usable for in-memory manipulation.
499 typedef struct diskNode {
506 /* Sort function for the sorted duplicate data items of a dn2id key.
507 * Sorts based on normalized RDN, in lexical order.
516 diskNode *usr = usrkey->data;
517 diskNode *cur = curkey->data;
518 short curlen, usrlen;
523 /* Make sure to detect negative values in the nrdnlen */
524 ptr = (char *)&usr->nrdnlen;
525 pt2 = (unsigned char *)(ptr+1);
527 usrlen = ptr[0] << 8 | *pt2;
529 ptr = (char *)&cur->nrdnlen;
530 pt2 = (unsigned char *)(ptr+1);
532 curlen = ptr[0] << 8 | *pt2;
535 if ( curlen < 0 ) return 0;
539 if ( curlen < 0 ) return 1;
541 rc = strncmp( usr->nrdn, cur->nrdn, usrlen );
542 if ( rc == 0 ) rc = usrlen - curlen;
546 /* This function constructs a full DN for a given entry.
553 int rlen = 0, nrlen = 0;
556 for ( ei = BEI(e); ei && ei->bei_id; ei=ei->bei_parent ) {
557 rlen += ei->bei_rdn.bv_len + 1;
558 nrlen += ei->bei_nrdn.bv_len + 1;
560 e->e_name.bv_len = rlen - 1;
561 e->e_nname.bv_len = nrlen - 1;
562 e->e_name.bv_val = ch_malloc(rlen + nrlen);
563 e->e_nname.bv_val = e->e_name.bv_val + rlen;
564 ptr = e->e_name.bv_val;
565 nptr = e->e_nname.bv_val;
566 for ( ei = BEI(e); ei && ei->bei_id; ei=ei->bei_parent ) {
567 ptr = lutil_strcopy(ptr, ei->bei_rdn.bv_val);
568 nptr = lutil_strcopy(nptr, ei->bei_nrdn.bv_val);
569 if ( ei->bei_parent ) {
580 /* We add two elements to the DN2ID database - a data item under the parent's
581 * entryID containing the child's RDN and entryID, and an item under the
582 * child's entryID containing the parent's entryID.
592 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
593 DB *db = bdb->bi_dn2id->bdi_db;
599 nrlen = dn_rdnlen( be, &e->e_nname );
601 rlen = dn_rdnlen( be, &e->e_name );
603 nrlen = e->e_nname.bv_len;
604 rlen = e->e_name.bv_len;
607 d = sl_malloc(sizeof(diskNode) + rlen + nrlen, ctx);
608 d->entryID = e->e_id;
610 ptr = lutil_strncopy( d->nrdn, e->e_nname.bv_val, nrlen );
612 ptr = lutil_strncopy( ptr, e->e_name.bv_val, rlen );
617 key.data = &eip->bei_id;
618 key.size = sizeof(ID);
619 key.flags = DB_DBT_USERMEM;
621 #ifdef SLAP_IDL_CACHE
622 if ( bdb->bi_idl_cache_size ) {
623 bdb_idl_cache_del( bdb, db, &key );
627 data.size = sizeof(diskNode) + rlen + nrlen;
628 data.flags = DB_DBT_USERMEM;
630 rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
634 d->entryID = eip->bei_id;
635 d->nrdnlen = 0 - nrlen;
637 rc = db->put( db, txn, &key, &data, DB_NODUPDATA );
653 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
654 DB *db = bdb->bi_dn2id->bdi_db;
661 key.size = sizeof(ID);
663 key.data = &eip->bei_id;
664 key.flags = DB_DBT_USERMEM;
667 data.size = sizeof(diskNode) + BEI(e)->bei_nrdn.bv_len;
668 data.ulen = data.size;
669 data.dlen = data.size;
670 data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
672 #ifdef SLAP_IDL_CACHE
673 if ( bdb->bi_idl_cache_size ) {
674 bdb_idl_cache_del( bdb, db, &key );
677 rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
680 d = sl_malloc( data.size, ctx );
681 d->entryID = e->e_id;
682 d->nrdnlen = BEI(e)->bei_nrdn.bv_len;
683 strcpy( d->nrdn, BEI(e)->bei_nrdn.bv_val );
686 /* Delete our ID from the parent's list */
687 rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH | DB_RMW );
689 rc = cursor->c_del( cursor, 0 );
691 /* Delete our ID from the tree. With sorted duplicates, this
692 * will leave any child nodes still hanging around. This is OK
693 * for modrdn, which will add our info back in later.
697 rc = cursor->c_get( cursor, &key, &data, DB_SET );
699 rc = cursor->c_del( cursor, 0 );
701 cursor->c_close( cursor );
715 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
716 DB *db = bdb->bi_dn2id->bdi_db;
722 ID idp = ei->bei_parent->bei_id;
724 nrlen = dn_rdnlen( be, in );
725 if (!nrlen) nrlen = in->bv_len;
728 key.size = sizeof(ID);
730 key.ulen = sizeof(ID);
731 key.flags = DB_DBT_USERMEM;
734 data.size = sizeof(diskNode) + nrlen;
735 data.ulen = data.size * 3;
736 data.flags = DB_DBT_USERMEM;
738 rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
741 d = sl_malloc( data.size * 3, ctx );
743 ptr = lutil_strncopy( d->nrdn, in->bv_val, nrlen );
747 rc = cursor->c_get( cursor, &key, &data, DB_GET_BOTH );
748 cursor->c_close( cursor );
751 AC_MEMCPY( &ei->bei_id, &d->entryID, sizeof(ID) );
752 ei->bei_rdn.bv_len = data.size - sizeof(diskNode) - nrlen;
753 ptr = d->nrdn + nrlen + 1;
754 ei->bei_rdn.bv_val = ch_malloc( ei->bei_rdn.bv_len + 1 );
755 strcpy( ei->bei_rdn.bv_val, ptr );
770 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
771 DB *db = bdb->bi_dn2id->bdi_db;
780 key.size = sizeof(ID);
781 key.data = &ei->bei_id;
782 key.ulen = sizeof(ID);
783 key.flags = DB_DBT_USERMEM;
786 data.flags = DB_DBT_USERMEM;
788 rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
791 data.ulen = sizeof(diskNode) + (SLAP_LDAPDN_MAXLEN * 2);
792 d = sl_malloc( data.ulen, ctx );
795 rc = cursor->c_get( cursor, &key, &data, DB_SET );
796 cursor->c_close( cursor );
798 if (d->nrdnlen >= 0) {
801 AC_MEMCPY( idp, &d->entryID, sizeof(ID) );
802 ei->bei_nrdn.bv_len = 0 - d->nrdnlen;
803 ber_str2bv( d->nrdn, ei->bei_nrdn.bv_len, 1, &ei->bei_nrdn );
804 ei->bei_rdn.bv_len = data.size - sizeof(diskNode) -
806 ptr = d->nrdn + ei->bei_nrdn.bv_len + 1;
807 ber_str2bv( ptr, ei->bei_rdn.bv_len, 1, &ei->bei_rdn );
819 struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
820 DB *db = bdb->bi_dn2id->bdi_db;
828 key.size = sizeof(ID);
830 key.flags = DB_DBT_USERMEM;
832 #ifdef SLAP_IDL_CACHE
833 if ( bdb->bi_idl_cache_size ) {
834 rc = bdb_idl_cache_get( bdb, db, &key, NULL );
835 if ( rc != LDAP_NO_SUCH_OBJECT ) {
842 data.ulen = sizeof(d);
843 data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
844 data.dlen = sizeof(d);
846 rc = db->cursor( db, txn, &cursor, bdb->bi_db_opflags );
849 rc = cursor->c_get( cursor, &key, &data, DB_SET );
851 rc = cursor->c_get( cursor, &key, &data, DB_NEXT_DUP );
853 cursor->c_close( cursor );
858 * We can't just use bdb_idl_fetch_key because
859 * 1 - our data items are longer than just an entry ID
860 * 2 - our data items are sorted alphabetically by nrdn, not by ID.
862 * We descend the tree recursively, so we define this cookie
863 * to hold our necessary state information. The bdb_dn2idl_internal
864 * function uses this cookie when calling itself.
867 struct dn2id_cookie {
868 struct bdb_info *bdb;
876 ID tmp[BDB_IDL_DB_SIZE];
886 struct dn2id_cookie *cx
889 #ifdef SLAP_IDL_CACHE
890 if ( cx->bdb->bi_idl_cache_size ) {
891 cx->rc = bdb_idl_cache_get(cx->bdb, cx->db, &cx->key, cx->tmp);
892 if ( cx->rc == DB_NOTFOUND ) {
895 if ( cx->rc == LDAP_SUCCESS ) {
901 cx->rc = cx->db->cursor( cx->db, NULL, &cx->dbc,
902 cx->bdb->bi_db_opflags );
903 if ( cx->rc ) return cx->rc;
904 BDB_IDL_ZERO( cx->tmp );
906 cx->data.data = &cx->dbuf;
907 cx->data.ulen = sizeof(ID);
908 cx->data.dlen = sizeof(ID);
909 cx->data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
911 /* The first item holds the parent ID. Ignore it. */
912 cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data, DB_SET );
913 if ( cx->rc == DB_NOTFOUND ) goto saveit;
914 if ( cx->rc ) return cx->rc;
916 cx->data.data = cx->buf;
917 cx->data.ulen = BDB_IDL_UM_SIZE * sizeof(ID);
918 cx->data.flags = DB_DBT_USERMEM;
920 /* Fetch the rest of the IDs in a loop... */
921 while ( (cx->rc = cx->dbc->c_get( cx->dbc, &cx->key, &cx->data,
922 DB_MULTIPLE | DB_NEXT_DUP )) == 0 ) {
925 DB_MULTIPLE_INIT( cx->ptr, &cx->data );
927 DB_MULTIPLE_NEXT( cx->ptr, &cx->data, j, len );
929 AC_MEMCPY( &cx->dbuf, j, sizeof(ID) );
930 bdb_idl_insert( cx->tmp, cx->dbuf );
934 cx->dbc->c_close( cx->dbc );
936 /* If we got some records, treat as success */
937 if (!BDB_IDL_IS_ZERO(cx->tmp)) {
942 #ifdef SLAP_IDL_CACHE
943 if ( cx->bdb->bi_idl_cache_max_size ) {
944 bdb_idl_cache_put( cx->bdb, cx->db, &cx->key, cx->tmp, cx->rc );
948 if ( cx->prefix == DN_SUBTREE_PREFIX ) {
951 save = sl_malloc( BDB_IDL_SIZEOF( cx->tmp ), cx->ctx );
952 BDB_IDL_CPY( save, cx->tmp );
953 bdb_idl_union( cx->ids, cx->tmp );
956 for ( cx->id = bdb_idl_first( save, &idcurs );
958 cx->id = bdb_idl_next( save, &idcurs )) {
959 bdb_dn2idl_internal( cx );
961 sl_free( save, cx->ctx );
964 BDB_IDL_CPY( cx->ids, cx->tmp );
979 struct dn2id_cookie cx;
980 EntryInfo *ei = (EntryInfo *)dn;
982 #ifndef BDB_MULTIPLE_SUFFIXES
983 if ( ei->bei_parent->bei_id == 0 ) {
984 struct bdb_info *bdb = (struct bdb_info *)be->be_private;
985 BDB_IDL_ALL( bdb, ids );
991 cx.bdb = (struct bdb_info *)be->be_private;
992 cx.db = cx.bdb->bi_dn2id->bdi_db;
999 if ( prefix == DN_SUBTREE_PREFIX ) {
1000 bdb_idl_insert( ids, cx.id );
1004 cx.key.data = &cx.id;
1005 cx.key.ulen = sizeof(ID);
1006 cx.key.size = sizeof(ID);
1007 cx.key.flags = DB_DBT_USERMEM;
1011 return bdb_dn2idl_internal(&cx);
1013 #endif /* BDB_HIER */