1 /* id2children.c - routines to deal with the id2children index */
11 #include "back-bdb2.h"
14 bdb2i_id2children_add(
26 ldbm_datum_init( key );
28 Debug( LDAP_DEBUG_TRACE, "=> bdb2i_id2children_add( %lu, %lu )\n",
29 p ? p->e_id : 0, e->e_id, 0 );
31 if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
32 LDBM_WRCREAT )) == NULL ) {
33 Debug( LDAP_DEBUG_ANY,
34 "<= bdb2i_id2children_add -1 could not open \"id2children%s\"\n",
39 sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
41 key.dsize = strlen( buf ) + 1;
43 if ( bdb2i_idl_insert_key( be, db, key, e->e_id ) != 0 ) {
44 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_add -1 (idl_insert)\n",
46 bdb2i_cache_close( be, db );
50 bdb2i_cache_close( be, db );
52 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_add 0\n", 0, 0, 0 );
58 bdb2i_id2children_remove(
70 Debug( LDAP_DEBUG_TRACE, "=> bdb2i_id2children_remove( %lu, %lu )\n",
71 p ? p->e_id : 0, e->e_id, 0 );
73 if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
74 LDBM_WRCREAT )) == NULL ) {
75 Debug( LDAP_DEBUG_ANY,
76 "<= bdb2i_id2children_remove -1 could not open \"id2children%s\"\n",
81 ldbm_datum_init( key );
82 sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
84 key.dsize = strlen( buf ) + 1;
86 if ( bdb2i_idl_delete_key( be, db, key, e->e_id ) != 0 ) {
87 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_remove -1 (idl_delete)\n",
89 bdb2i_cache_close( be, db );
93 bdb2i_cache_close( be, db );
95 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_id2children_remove 0\n", 0, 0, 0 );
111 ldbm_datum_init( key );
113 Debug( LDAP_DEBUG_TRACE, "=> bdb2i_has_children( %lu )\n", p->e_id , 0, 0 );
115 if ( (db = bdb2i_cache_open( be, "id2children", BDB2_SUFFIX,
116 LDBM_WRCREAT )) == NULL ) {
117 Debug( LDAP_DEBUG_ANY,
118 "<= bdb2i_has_children -1 could not open \"id2children%s\"\n",
123 sprintf( buf, "%c%ld", EQ_PREFIX, p->e_id );
125 key.dsize = strlen( buf ) + 1;
127 idl = bdb2i_idl_fetch( be, db, key );
129 bdb2i_cache_close( be, db );
132 bdb2i_idl_free( idl );
136 Debug( LDAP_DEBUG_TRACE, "<= bdb2i_has_children( %lu ): %s\n",
137 p->e_id, rc ? "yes" : "no", 0 );