1 /* init.c - initialize bdb backend */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2005 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
20 #include <ac/string.h>
21 #include <ac/unistd.h>
22 #include <ac/stdlib.h>
30 static const struct bdbi_database {
35 } bdbi_databases[] = {
36 { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
37 { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
41 typedef void * db_malloc(size_t);
42 typedef void * db_realloc(void *, size_t);
45 bdb_db_init( BackendDB *be )
49 Debug( LDAP_DEBUG_TRACE,
50 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
53 /* allocate backend-database-specific stuff */
54 bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
56 /* DBEnv parameters */
57 bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
58 bdb->bi_dbenv_xflags = 0;
59 bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
61 bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
63 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
64 bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
65 bdb->bi_search_stack = NULL;
67 ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
68 ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
69 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
70 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
71 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
74 be->be_cf_table = be->bd_info->bi_cf_table;
80 bdb_checkpoint( void *ctx, void *arg )
82 struct re_s *rtask = arg;
83 struct bdb_info *bdb = rtask->arg;
85 TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte,
86 bdb->bi_txn_cp_min, 0 );
87 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
88 ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
89 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
94 * Unconditionally perform a database recovery. Only works on
95 * databases that were previously opened with transactions and
99 bdb_do_recovery( BackendDB *be )
101 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
105 char path[MAXPATHLEN], *ptr;
107 /* Create and init the recovery environment */
108 rc = db_env_create( &re_dbenv, 0 );
110 Debug( LDAP_DEBUG_ANY,
111 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
112 db_strerror(rc), rc, 0 );
115 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
116 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
117 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
118 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
120 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
121 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
123 /* Open the environment, which will also perform the recovery */
125 strcpy( path, bdb->bi_dbenv_home );
127 rc = re_dbenv->open( re_dbenv,
130 bdb->bi_dbenv_mode );
132 rc = re_dbenv->open( re_dbenv,
135 bdb->bi_dbenv_mode );
138 Debug( LDAP_DEBUG_ANY,
139 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
140 db_strerror(rc), rc, 0 );
143 (void) re_dbenv->close( re_dbenv, 0 );
145 /* By convention we reset the mtime for id2entry.bdb to the current time */
146 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
147 *ptr++ = LDAP_DIRSEP[0];
148 strcpy( ptr, bdbi_databases[0].file);
149 (void) utime( path, NULL);
155 * Database recovery logic:
156 * This function is called whenever the database appears to have been
157 * shut down uncleanly, as determined by the alock functions.
158 * Because of the -q function in slapadd, there is also the possibility
159 * that the shutdown happened when transactions weren't being used and
160 * the database is likely to be corrupt. The function checks for this
161 * condition by examining the environment to make sure it had previously
162 * been opened with transactions enabled. If this is the case, the
163 * database is recovered as usual. If transactions were not enabled,
164 * then this function will return a fail.
167 bdb_db_recover( BackendDB *be )
169 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
174 char path[MAXPATHLEN];
177 /* Create the recovery environment, then open it.
178 * We use the DB_JOIN in combination with a flags value of
179 * zero so we join an existing environment and can read the
180 * value of the flags that were used the last time the
181 * environment was opened. DB_CREATE is added because the
182 * open would fail if the only thing that had been done
183 * was an open with transactions and logs disabled.
185 rc = db_env_create( &re_dbenv, 0 );
187 Debug( LDAP_DEBUG_ANY,
188 "bdb_db_recover: db_env_create failed: %s (%d)\n",
189 db_strerror(rc), rc, 0 );
192 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
193 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
195 Debug( LDAP_DEBUG_TRACE,
196 "bdb_db_recover: dbenv_open(%s)\n",
197 bdb->bi_dbenv_home, 0, 0);
200 strcpy( path, bdb->bi_dbenv_home );
202 rc = re_dbenv->open( re_dbenv,
205 bdb->bi_dbenv_mode );
207 rc = re_dbenv->open( re_dbenv,
210 bdb->bi_dbenv_mode );
217 Debug( LDAP_DEBUG_ANY,
218 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
219 db_strerror(rc), rc, 0 );
224 * Check the flags that had been used in the previous open.
225 * The environment needed to have had both
226 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
227 * recover the database. Otherwise the an app failed while running
228 * without transactions and logs enabled and the dn2id and id2entry
229 * mapping is likely to be corrupt.
231 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
233 Debug( LDAP_DEBUG_ANY,
234 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
235 db_strerror(rc), rc, 0 );
239 (void) re_dbenv->close( re_dbenv, 0 );
241 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
242 return bdb_do_recovery( be );
246 Debug( LDAP_DEBUG_ANY,
247 "bdb_db_recover: Database cannot be recovered. "\
248 "Restore from backup!\n", 0, 0, 0);
255 bdb_db_open( BackendDB *be )
258 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
259 struct stat stat1, stat2;
261 char path[MAXPATHLEN];
264 Debug( LDAP_DEBUG_ARGS,
266 be->be_suffix[0].bv_val, 0, 0 );
268 #ifndef BDB_MULTIPLE_SUFFIXES
269 if ( be->be_suffix[1].bv_val ) {
270 Debug( LDAP_DEBUG_ANY,
271 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
276 /* Check existence of dbenv_home. Any error means trouble */
277 rc = stat( bdb->bi_dbenv_home, &stat1 );
279 Debug( LDAP_DEBUG_ANY,
280 "bdb_db_open: Cannot access database directory %s (%d)\n",
281 bdb->bi_dbenv_home, errno, 0 );
285 /* Perform database use arbitration/recovery logic */
286 rc = alock_open( &bdb->bi_alock_info,
289 slapMode & SLAP_TOOL_READONLY ?
290 ALOCK_LOCKED : ALOCK_UNIQUE );
292 if( rc == ALOCK_RECOVER ) {
293 Debug( LDAP_DEBUG_ANY,
294 "bdb_db_open: unclean shutdown detected;"
295 " attempting recovery.\n",
297 if( bdb_db_recover( be ) != 0 ) {
298 Debug( LDAP_DEBUG_ANY,
299 "bdb_db_open: DB recovery failed.\n",
303 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
304 Debug( LDAP_DEBUG_ANY,
305 "bdb_db_open: alock_recover failed\n",
310 } else if( rc == ALOCK_BUSY ) {
311 Debug( LDAP_DEBUG_ANY,
312 "bdb_db_open: database already in use\n",
315 } else if( rc != ALOCK_CLEAN ) {
316 Debug( LDAP_DEBUG_ANY,
317 "bdb_db_open: alock package is unstable\n",
323 * The DB_CONFIG file may have changed. If so, recover the
324 * database so that new settings are put into effect. Also
325 * note the possible absence of DB_CONFIG in the log.
327 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
328 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
329 *ptr++ = LDAP_DIRSEP[0];
330 strcpy( ptr, bdbi_databases[0].file);
331 if( stat( path, &stat2 ) == 0 ) {
332 if( stat2.st_mtime <= stat1.st_mtime ) {
333 Debug( LDAP_DEBUG_ANY,
334 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
335 "Performing database recovery to activate new settings.\n",
336 be->be_suffix[0].bv_val, 0, 0 );
337 if( bdb_do_recovery( be ) != 0) {
338 Debug( LDAP_DEBUG_ANY,
339 "bdb_db_open: db recovery failed.\n",
348 Debug( LDAP_DEBUG_ANY,
349 "bdb_db_open: Warning - No DB_CONFIG file found "
350 "in directory %s: (%d)\n"
351 "Expect poor performance for suffix %s.\n",
352 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
355 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
356 if ( !( slapMode & SLAP_TOOL_QUICK ))
357 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
359 rc = db_env_create( &bdb->bi_dbenv, 0 );
361 Debug( LDAP_DEBUG_ANY,
362 "bdb_db_open: db_env_create failed: %s (%d)\n",
363 db_strerror(rc), rc, 0 );
367 /* If a key was set, use shared memory for the BDB environment */
368 if ( bdb->bi_shm_key ) {
369 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
370 flags |= DB_SYSTEM_MEM;
373 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
374 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
375 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
377 /* One long-lived TXN per thread, two TXNs per write op */
378 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
380 #ifdef SLAP_ZONE_ALLOC
381 if ( bdb->bi_cache.c_maxsize ) {
382 bdb->bi_cache.c_zctx = slap_zn_mem_create(
390 if ( bdb->bi_idl_cache_max_size ) {
391 bdb->bi_idl_tree = NULL;
392 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
393 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
394 bdb->bi_idl_cache_size = 0;
397 if( bdb->bi_dbenv_xflags != 0 ) {
398 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
399 bdb->bi_dbenv_xflags, 1);
401 Debug( LDAP_DEBUG_ANY,
402 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
403 db_strerror(rc), rc, 0 );
408 Debug( LDAP_DEBUG_TRACE,
409 "bdb_db_open: dbenv_open(%s)\n",
410 bdb->bi_dbenv_home, 0, 0);
413 strcpy( path, bdb->bi_dbenv_home );
415 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
418 bdb->bi_dbenv_mode );
420 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
423 bdb->bi_dbenv_mode );
426 Debug( LDAP_DEBUG_ANY,
427 "bdb_db_open: dbenv_open failed: %s (%d)\n",
428 db_strerror(rc), rc, 0 );
432 flags = DB_THREAD | bdb->bi_db_opflags;
434 #ifdef DB_AUTO_COMMIT
435 if ( !( slapMode & SLAP_TOOL_QUICK ))
436 flags |= DB_AUTO_COMMIT;
439 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
440 BDB_INDICES * sizeof(struct bdb_db_info *) );
442 /* open (and create) main database */
443 for( i = 0; bdbi_databases[i].name; i++ ) {
444 struct bdb_db_info *db;
446 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
448 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
450 Debug( LDAP_DEBUG_ANY,
451 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
452 bdb->bi_dbenv_home, db_strerror(rc), rc );
456 if( i == BDB_ID2ENTRY ) {
457 rc = db->bdi_db->set_pagesize( db->bdi_db,
458 BDB_ID2ENTRY_PAGESIZE );
459 if ( slapMode & SLAP_TOOL_READMAIN ) {
465 rc = db->bdi_db->set_flags( db->bdi_db,
466 DB_DUP | DB_DUPSORT );
468 if ( slapMode & SLAP_TOOL_READONLY ) {
474 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
480 rc = db->bdi_db->set_pagesize( db->bdi_db,
485 strcpy( path, bdbi_databases[i].file );
487 rc = DB_OPEN( db->bdi_db,
489 /* bdbi_databases[i].name, */ NULL,
490 bdbi_databases[i].type,
491 bdbi_databases[i].flags | flags,
492 bdb->bi_dbenv_mode );
494 rc = DB_OPEN( db->bdi_db,
495 bdbi_databases[i].file,
496 /* bdbi_databases[i].name, */ NULL,
497 bdbi_databases[i].type,
498 bdbi_databases[i].flags | flags,
499 bdb->bi_dbenv_mode );
503 char buf[SLAP_TEXT_BUFLEN];
505 snprintf( buf, sizeof(buf), "%s/%s",
506 bdb->bi_dbenv_home, bdbi_databases[i].file );
507 Debug( LDAP_DEBUG_ANY,
508 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
509 buf, db_strerror(rc), rc );
513 flags &= ~(DB_CREATE | DB_RDONLY);
514 db->bdi_name = bdbi_databases[i].name;
515 bdb->bi_databases[i] = db;
518 bdb->bi_databases[i] = NULL;
519 bdb->bi_ndatabases = i;
522 rc = bdb_last_id( be, NULL );
524 Debug( LDAP_DEBUG_ANY,
525 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
526 bdb->bi_dbenv_home, db_strerror(rc), rc );
530 if ( !( slapMode & SLAP_TOOL_QUICK )) {
531 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
534 /* If we're in server mode and time-based checkpointing is enabled,
535 * submit a task to perform periodic checkpoints.
537 if (( slapMode & SLAP_SERVER_MODE ) && bdb->bi_txn_cp &&
538 bdb->bi_txn_cp_min ) {
539 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
540 ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min*60,
541 bdb_checkpoint, bdb );
542 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
545 if ( slapMode & SLAP_SERVER_MODE && bdb->bi_db_has_config ) {
546 char buf[SLAP_TEXT_BUFLEN];
547 FILE *f = fopen( bdb->bi_db_config_path, "r" );
551 while ( fgets( buf, sizeof(buf), f )) {
552 ber_str2bv( buf, 0, 1, &bv );
553 if ( bv.bv_val[bv.bv_len-1] == '\n' ) {
555 bv.bv_val[bv.bv_len] = '\0';
557 /* shouldn't need this, but ... */
558 if ( bv.bv_val[bv.bv_len-1] == '\r' ) {
560 bv.bv_val[bv.bv_len] = '\0';
562 ber_bvarray_add( &bdb->bi_db_config, &bv );
566 /* Eh? It disappeared between config and open?? */
567 bdb->bi_db_has_config = 0;
571 bdb->bi_db_is_open = 1;
577 bdb_db_close( BackendDB *be )
580 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
581 struct bdb_db_info *db;
582 bdb_idl_cache_entry_t *entry, *next_entry;
584 bdb->bi_db_is_open = 0;
586 ber_bvarray_free( bdb->bi_db_config );
588 while( bdb->bi_ndatabases-- ) {
589 db = bdb->bi_databases[bdb->bi_ndatabases];
590 rc = db->bdi_db->close( db->bdi_db, 0 );
591 /* Lower numbered names are not strdup'd */
592 if( bdb->bi_ndatabases >= BDB_NDB )
593 free( db->bdi_name );
596 free( bdb->bi_databases );
597 bdb_attr_index_destroy( bdb->bi_attrs );
599 bdb_cache_release_all (&bdb->bi_cache);
601 if ( bdb->bi_idl_cache_max_size ) {
602 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
603 avl_free( bdb->bi_idl_tree, NULL );
604 entry = bdb->bi_idl_lru_head;
605 while ( entry != NULL ) {
606 next_entry = entry->idl_lru_next;
609 free( entry->kstr.bv_val );
613 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
616 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
617 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
624 bdb_db_destroy( BackendDB *be )
627 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
629 /* close db environment */
630 if( bdb->bi_dbenv ) {
631 /* force a checkpoint */
632 if ( !( slapMode & SLAP_TOOL_QUICK )) {
633 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
635 Debug( LDAP_DEBUG_ANY,
636 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
637 db_strerror(rc), rc, 0 );
641 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
642 bdb->bi_dbenv = NULL;
644 Debug( LDAP_DEBUG_ANY,
645 "bdb_db_destroy: close failed: %s (%d)\n",
646 db_strerror(rc), rc, 0 );
651 rc = alock_close( &bdb->bi_alock_info );
653 Debug( LDAP_DEBUG_ANY,
654 "bdb_db_destroy: alock_close failed\n", 0, 0, 0 );
658 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
659 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
661 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
662 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
663 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
664 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
665 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
666 if ( bdb->bi_idl_cache_max_size ) {
667 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
668 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
672 be->be_private = NULL;
683 static char *controls[] = {
685 LDAP_CONTROL_MANAGEDSAIT,
687 LDAP_CONTROL_PAGEDRESULTS,
688 #ifdef LDAP_CONTROL_SUBENTRIES
689 LDAP_CONTROL_SUBENTRIES,
691 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
692 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
697 /* initialize the underlying database system */
698 Debug( LDAP_DEBUG_TRACE,
699 LDAP_XSTRING(bdb_back_initialize) ": initialize "
700 BDB_UCTYPE " backend\n", 0, 0, 0 );
703 SLAP_BFLAG_INCREMENT |
704 #ifdef BDB_SUBENTRIES
705 SLAP_BFLAG_SUBENTRIES |
708 SLAP_BFLAG_REFERRALS;
710 bi->bi_controls = controls;
712 { /* version check */
713 int major, minor, patch, ver;
714 char *version = db_version( &major, &minor, &patch );
718 /* All our stdio does an ASCII to EBCDIC conversion on
719 * the output. Strings from the BDB library are already
720 * in EBCDIC; we have to go back and forth...
722 strcpy( v2, version );
727 ver = (major << 24) | (minor << 16) | patch;
728 if( ver != DB_VERSION_FULL ) {
729 /* fail if a versions don't match */
730 Debug( LDAP_DEBUG_ANY,
731 LDAP_XSTRING(bdb_back_initialize) ": "
732 "BDB library version mismatch:"
733 " expected " DB_VERSION_STRING ","
734 " got %s\n", version, 0, 0 );
738 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
739 ": %s\n", version, 0, 0 );
742 db_env_set_func_free( ber_memfree );
743 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
744 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
746 /* This is a no-op on a NO_THREAD build. Leave the default
747 * alone so that BDB will sleep on interprocess conflicts.
749 db_env_set_func_yield( ldap_pvt_thread_yield );
757 bi->bi_db_init = bdb_db_init;
758 bi->bi_db_config = config_generic_wrapper;
759 bi->bi_db_open = bdb_db_open;
760 bi->bi_db_close = bdb_db_close;
761 bi->bi_db_destroy = bdb_db_destroy;
763 bi->bi_op_add = bdb_add;
764 bi->bi_op_bind = bdb_bind;
765 bi->bi_op_compare = bdb_compare;
766 bi->bi_op_delete = bdb_delete;
767 bi->bi_op_modify = bdb_modify;
768 bi->bi_op_modrdn = bdb_modrdn;
769 bi->bi_op_search = bdb_search;
771 bi->bi_op_unbind = 0;
773 bi->bi_extended = bdb_extended;
775 bi->bi_chk_referrals = bdb_referrals;
776 bi->bi_operational = bdb_operational;
777 bi->bi_has_subordinates = bdb_hasSubordinates;
778 bi->bi_entry_release_rw = bdb_entry_release;
779 bi->bi_entry_get_rw = bdb_entry_get;
782 * hooks for slap tools
784 bi->bi_tool_entry_open = bdb_tool_entry_open;
785 bi->bi_tool_entry_close = bdb_tool_entry_close;
786 bi->bi_tool_entry_first = bdb_tool_entry_next;
787 bi->bi_tool_entry_next = bdb_tool_entry_next;
788 bi->bi_tool_entry_get = bdb_tool_entry_get;
789 bi->bi_tool_entry_put = bdb_tool_entry_put;
790 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
791 bi->bi_tool_sync = 0;
792 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
793 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
794 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
796 bi->bi_connection_init = 0;
797 bi->bi_connection_destroy = 0;
799 rc = bdb_back_init_cf( bi );
804 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
805 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
807 /* conditionally define the init_module() function */
809 SLAP_BACKEND_INIT_MODULE( hdb )
810 #else /* !BDB_HIER */
811 SLAP_BACKEND_INIT_MODULE( bdb )
812 #endif /* !BDB_HIER */
814 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */