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>
26 # ifdef HAVE_SYS_TYPES_H
27 # include <sys/types.h>
30 #endif /* HAVE_UTIME_H */
36 static const struct bdbi_database {
41 } bdbi_databases[] = {
42 { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
43 { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
47 typedef void * db_malloc(size_t);
48 typedef void * db_realloc(void *, size_t);
51 bdb_db_init( BackendDB *be )
55 Debug( LDAP_DEBUG_TRACE,
56 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
59 /* allocate backend-database-specific stuff */
60 bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
62 /* DBEnv parameters */
63 bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
64 bdb->bi_dbenv_xflags = 0;
65 bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
67 bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
69 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
70 bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
71 bdb->bi_search_stack = NULL;
73 ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
74 ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
76 ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex );
78 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
79 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
80 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
81 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
82 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
85 be->be_cf_ocs = be->bd_info->bi_cf_ocs;
91 bdb_db_open( BackendDB *be )
94 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
95 struct stat stat1, stat2;
97 char path[MAXPATHLEN];
99 int do_recover = 0, do_alock_recover = 0, open_env = 1, got_env = 0;
101 if ( be->be_suffix == NULL ) {
102 Debug( LDAP_DEBUG_ANY,
103 "bdb_db_open: need suffix\n",
108 Debug( LDAP_DEBUG_ARGS,
110 be->be_suffix[0].bv_val, 0, 0 );
112 #ifndef BDB_MULTIPLE_SUFFIXES
113 if ( be->be_suffix[1].bv_val ) {
114 Debug( LDAP_DEBUG_ANY,
115 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
120 /* Check existence of dbenv_home. Any error means trouble */
121 rc = stat( bdb->bi_dbenv_home, &stat1 );
123 Debug( LDAP_DEBUG_ANY,
124 "bdb_db_open: Cannot access database directory %s (%d)\n",
125 bdb->bi_dbenv_home, errno, 0 );
129 /* Perform database use arbitration/recovery logic */
130 rc = alock_open( &bdb->bi_alock_info,
133 slapMode & SLAP_TOOL_READONLY ?
134 ALOCK_LOCKED : ALOCK_UNIQUE );
136 if( rc == ALOCK_RECOVER ) {
137 Debug( LDAP_DEBUG_ANY,
138 "bdb_db_open: unclean shutdown detected;"
139 " attempting recovery.\n",
141 do_alock_recover = 1;
143 } else if( rc == ALOCK_BUSY ) {
144 Debug( LDAP_DEBUG_ANY,
145 "bdb_db_open: database already in use\n",
148 } else if( rc != ALOCK_CLEAN ) {
149 Debug( LDAP_DEBUG_ANY,
150 "bdb_db_open: alock package is unstable\n",
156 * The DB_CONFIG file may have changed. If so, recover the
157 * database so that new settings are put into effect. Also
158 * note the possible absence of DB_CONFIG in the log.
160 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
162 char *ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
163 *ptr++ = LDAP_DIRSEP[0];
164 strcpy( ptr, "__db.001" );
165 if( stat( path, &stat2 ) == 0 ) {
166 if( stat2.st_mtime <= stat1.st_mtime ) {
167 Debug( LDAP_DEBUG_ANY,
168 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
169 "Performing database recovery to activate new settings.\n",
170 be->be_suffix[0].bv_val, 0, 0 );
177 Debug( LDAP_DEBUG_ANY,
178 "bdb_db_open: Warning - No DB_CONFIG file found "
179 "in directory %s: (%d)\n"
180 "Expect poor performance for suffix %s.\n",
181 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
184 rc = db_env_create( &bdb->bi_dbenv, 0 );
186 Debug( LDAP_DEBUG_ANY,
187 "bdb_db_open: db_env_create failed: %s (%d)\n",
188 db_strerror(rc), rc, 0 );
192 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
193 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
195 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
197 /* One long-lived TXN per thread, two TXNs per write op */
198 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
200 if( bdb->bi_dbenv_xflags != 0 ) {
201 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
202 bdb->bi_dbenv_xflags, 1);
204 Debug( LDAP_DEBUG_ANY,
205 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
206 db_strerror(rc), rc, 0 );
211 #define BDB_TXN_FLAGS (DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN)
214 strcpy( path, bdb->bi_dbenv_home );
218 dbhome = bdb->bi_dbenv_home;
221 Debug( LDAP_DEBUG_TRACE,
222 "bdb_db_open: dbenv_open(%s)\n",
223 bdb->bi_dbenv_home, 0, 0);
225 /* Check if there is a usable existing environment */
226 flags = DB_JOINENV | DB_THREAD;
228 rc = bdb->bi_dbenv->open( bdb->bi_dbenv, dbhome,
229 flags, bdb->bi_dbenv_mode );
235 rc = bdb->bi_dbenv->get_open_flags( bdb->bi_dbenv, &flags );
237 int flag2 = flags & BDB_TXN_FLAGS;
239 /* In quick mode, none of these flags are allowed */
240 if ( slapMode & SLAP_TOOL_QUICK ) {
244 /* In normal mode, all of these flags are required */
245 if ( flag2 == BDB_TXN_FLAGS )
250 /* In Quick mode, we cannot Recover... */
251 if ( slapMode & SLAP_TOOL_QUICK ) {
252 /* If we need to recover but we had no TXNs, just fail */
253 if ( do_recover && flags_ok ) {
254 Debug( LDAP_DEBUG_ANY,
255 "bdb_db_open: Database cannot be recovered. "
256 "Restore from backup!\n", 0, 0, 0);
259 /* We need to recover, and we had TXN support before:
260 * Close this env, open a new one with recovery flags.
263 bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
264 bdb->bi_dbenv = NULL;
265 rc = db_env_create( &bdb->bi_dbenv, 0 );
267 Debug( LDAP_DEBUG_ANY,
268 "bdb_db_open: db_env_create failed: %s (%d)\n",
269 db_strerror(rc), rc, 0 );
272 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv,
273 be->be_suffix[0].bv_val );
274 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
275 rc = bdb->bi_dbenv->open( bdb->bi_dbenv, dbhome,
276 flags | DB_RECOVER, bdb->bi_dbenv_mode );
278 Debug( LDAP_DEBUG_ANY,
279 "bdb_db_open: recovery failed: %s (%d)\n",
280 db_strerror(rc), rc, 0 );
285 /* Prev environment had TXN support, get rid of it */
287 bdb->bi_dbenv->remove( bdb->bi_dbenv, dbhome, 0 );
288 bdb->bi_dbenv = NULL;
290 /* Normal TXN mode */
292 /* If we need to recover but we had no TXNs, just fail */
293 if ( do_recover && !flags_ok ) {
294 Debug( LDAP_DEBUG_ANY,
295 "bdb_db_open: Database cannot be recovered. "
296 "Restore from backup!\n", 0, 0, 0);
299 /* Prev environment had no TXN support, close it */
301 bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
302 bdb->bi_dbenv = NULL;
307 if ( flags_ok && !do_recover ) {
308 /* This environment is fine, don't reopen it */
311 /* Create a new env that can take the desired settings */
312 rc = db_env_create( &bdb->bi_dbenv, 0 );
314 Debug( LDAP_DEBUG_ANY,
315 "bdb_db_open: db_env_create failed: %s (%d)\n",
316 db_strerror(rc), rc, 0 );
320 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
321 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
322 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
324 /* One long-lived TXN per thread, two TXNs per write op */
325 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
327 if( bdb->bi_dbenv_xflags != 0 ) {
328 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
329 bdb->bi_dbenv_xflags, 1);
331 Debug( LDAP_DEBUG_ANY,
332 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
333 db_strerror(rc), rc, 0 );
340 /* If we need to recover but there was no existing environment,
341 * then we assume that someone has already manually recovered using
342 * db_recover. Just ignore it.
344 if ( do_recover && !got_env ) {
346 Debug( LDAP_DEBUG_TRACE,
347 "bdb_db_open: Recovery needed but environment is missing - "
348 "assuming recovery was done manually...\n", 0, 0, 0 );
352 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
353 if ( !( slapMode & SLAP_TOOL_QUICK ))
354 flags |= BDB_TXN_FLAGS;
359 /* If a key was set, use shared memory for the BDB environment */
360 if ( bdb->bi_shm_key ) {
361 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
362 flags |= DB_SYSTEM_MEM;
365 rc = bdb->bi_dbenv->open( bdb->bi_dbenv, dbhome,
366 flags, bdb->bi_dbenv_mode );
368 Debug( LDAP_DEBUG_ANY,
369 "bdb_db_open: dbenv_open failed: %s (%d)\n",
370 db_strerror(rc), rc, 0 );
375 if ( do_alock_recover && alock_recover (&bdb->bi_alock_info) != 0 ) {
376 Debug( LDAP_DEBUG_ANY,
377 "bdb_db_open: alock_recover failed\n",
382 #ifdef SLAP_ZONE_ALLOC
383 if ( bdb->bi_cache.c_maxsize ) {
384 bdb->bi_cache.c_zctx = slap_zn_mem_create(
392 if ( bdb->bi_idl_cache_max_size ) {
393 bdb->bi_idl_tree = NULL;
394 bdb->bi_idl_cache_size = 0;
397 flags = DB_THREAD | bdb->bi_db_opflags;
399 #ifdef DB_AUTO_COMMIT
400 if ( !( slapMode & SLAP_TOOL_QUICK ))
401 flags |= DB_AUTO_COMMIT;
404 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
405 BDB_INDICES * sizeof(struct bdb_db_info *) );
407 /* open (and create) main database */
408 for( i = 0; bdbi_databases[i].name; i++ ) {
409 struct bdb_db_info *db;
411 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
413 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
415 Debug( LDAP_DEBUG_ANY,
416 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
417 bdb->bi_dbenv_home, db_strerror(rc), rc );
421 if( i == BDB_ID2ENTRY ) {
422 rc = db->bdi_db->set_pagesize( db->bdi_db,
423 BDB_ID2ENTRY_PAGESIZE );
424 if ( slapMode & SLAP_TOOL_READMAIN ) {
430 rc = db->bdi_db->set_flags( db->bdi_db,
431 DB_DUP | DB_DUPSORT );
433 if ( slapMode & SLAP_TOOL_READONLY ) {
439 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
445 rc = db->bdi_db->set_pagesize( db->bdi_db,
450 strcpy( path, bdbi_databases[i].file );
452 rc = DB_OPEN( db->bdi_db,
454 /* bdbi_databases[i].name, */ NULL,
455 bdbi_databases[i].type,
456 bdbi_databases[i].flags | flags,
457 bdb->bi_dbenv_mode );
459 rc = DB_OPEN( db->bdi_db,
460 bdbi_databases[i].file,
461 /* bdbi_databases[i].name, */ NULL,
462 bdbi_databases[i].type,
463 bdbi_databases[i].flags | flags,
464 bdb->bi_dbenv_mode );
468 char buf[SLAP_TEXT_BUFLEN];
470 snprintf( buf, sizeof(buf), "%s/%s",
471 bdb->bi_dbenv_home, bdbi_databases[i].file );
472 Debug( LDAP_DEBUG_ANY,
473 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
474 buf, db_strerror(rc), rc );
479 if( i == BDB_ID2ENTRY && ( slapMode & SLAP_TOOL_MODE )) {
480 db->bdi_db->mpf->set_priority( db->bdi_db->mpf,
481 DB_PRIORITY_VERY_LOW );
485 flags &= ~(DB_CREATE | DB_RDONLY);
486 db->bdi_name = bdbi_databases[i].name;
487 bdb->bi_databases[i] = db;
490 bdb->bi_databases[i] = NULL;
491 bdb->bi_ndatabases = i;
494 rc = bdb_last_id( be, NULL );
496 Debug( LDAP_DEBUG_ANY,
497 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
498 bdb->bi_dbenv_home, db_strerror(rc), rc );
502 if ( !( slapMode & SLAP_TOOL_QUICK )) {
503 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
506 bdb->bi_flags |= BDB_IS_OPEN;
512 bdb_db_close( BackendDB *be )
515 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
516 struct bdb_db_info *db;
517 bdb_idl_cache_entry_t *entry, *next_entry;
519 /* backend_shutdown closes everything, even if not all were opened */
520 if ( !( bdb->bi_flags & BDB_IS_OPEN ))
523 bdb->bi_flags &= ~BDB_IS_OPEN;
525 ber_bvarray_free( bdb->bi_db_config );
526 bdb->bi_db_config = NULL;
528 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
529 db = bdb->bi_databases[bdb->bi_ndatabases];
530 rc = db->bdi_db->close( db->bdi_db, 0 );
531 /* Lower numbered names are not strdup'd */
532 if( bdb->bi_ndatabases >= BDB_NDB )
533 free( db->bdi_name );
536 free( bdb->bi_databases );
537 bdb->bi_databases = NULL;
539 bdb_cache_release_all (&bdb->bi_cache);
541 if ( bdb->bi_idl_cache_max_size ) {
542 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
543 avl_free( bdb->bi_idl_tree, NULL );
544 bdb->bi_idl_tree = NULL;
545 entry = bdb->bi_idl_lru_head;
546 while ( entry != NULL ) {
547 next_entry = entry->idl_lru_next;
550 free( entry->kstr.bv_val );
554 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
555 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
558 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
559 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
560 bdb->bi_cache.c_locker = 0;
563 /* close db environment */
564 if( bdb->bi_dbenv ) {
565 /* force a checkpoint, but not if we were ReadOnly,
566 * and not in Quick mode since there are no transactions there.
568 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
569 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
571 Debug( LDAP_DEBUG_ANY,
572 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
573 db_strerror(rc), rc, 0 );
577 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
578 bdb->bi_dbenv = NULL;
580 Debug( LDAP_DEBUG_ANY,
581 "bdb_db_close: close failed: %s (%d)\n",
582 db_strerror(rc), rc, 0 );
587 rc = alock_close( &bdb->bi_alock_info );
589 Debug( LDAP_DEBUG_ANY,
590 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
598 bdb_db_destroy( BackendDB *be )
600 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
602 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
603 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
605 bdb_attr_index_destroy( bdb->bi_attrs );
607 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
608 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
609 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
611 ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
613 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
614 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
615 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
616 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
619 be->be_private = NULL;
630 static char *controls[] = {
632 LDAP_CONTROL_MANAGEDSAIT,
634 LDAP_CONTROL_PAGEDRESULTS,
635 #ifdef LDAP_CONTROL_SUBENTRIES
636 LDAP_CONTROL_SUBENTRIES,
638 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
639 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
644 /* initialize the underlying database system */
645 Debug( LDAP_DEBUG_TRACE,
646 LDAP_XSTRING(bdb_back_initialize) ": initialize "
647 BDB_UCTYPE " backend\n", 0, 0, 0 );
650 SLAP_BFLAG_INCREMENT |
651 #ifdef BDB_SUBENTRIES
652 SLAP_BFLAG_SUBENTRIES |
655 SLAP_BFLAG_REFERRALS;
657 bi->bi_controls = controls;
659 { /* version check */
660 int major, minor, patch, ver;
661 char *version = db_version( &major, &minor, &patch );
665 /* All our stdio does an ASCII to EBCDIC conversion on
666 * the output. Strings from the BDB library are already
667 * in EBCDIC; we have to go back and forth...
669 strcpy( v2, version );
674 ver = (major << 24) | (minor << 16) | patch;
675 if( ver != DB_VERSION_FULL ) {
676 /* fail if a versions don't match */
677 Debug( LDAP_DEBUG_ANY,
678 LDAP_XSTRING(bdb_back_initialize) ": "
679 "BDB library version mismatch:"
680 " expected " DB_VERSION_STRING ","
681 " got %s\n", version, 0, 0 );
685 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
686 ": %s\n", version, 0, 0 );
689 db_env_set_func_free( ber_memfree );
690 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
691 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
693 /* This is a no-op on a NO_THREAD build. Leave the default
694 * alone so that BDB will sleep on interprocess conflicts.
696 db_env_set_func_yield( ldap_pvt_thread_yield );
704 bi->bi_db_init = bdb_db_init;
705 bi->bi_db_config = config_generic_wrapper;
706 bi->bi_db_open = bdb_db_open;
707 bi->bi_db_close = bdb_db_close;
708 bi->bi_db_destroy = bdb_db_destroy;
710 bi->bi_op_add = bdb_add;
711 bi->bi_op_bind = bdb_bind;
712 bi->bi_op_compare = bdb_compare;
713 bi->bi_op_delete = bdb_delete;
714 bi->bi_op_modify = bdb_modify;
715 bi->bi_op_modrdn = bdb_modrdn;
716 bi->bi_op_search = bdb_search;
718 bi->bi_op_unbind = 0;
720 bi->bi_extended = bdb_extended;
722 bi->bi_chk_referrals = bdb_referrals;
723 bi->bi_operational = bdb_operational;
724 bi->bi_has_subordinates = bdb_hasSubordinates;
725 bi->bi_entry_release_rw = bdb_entry_release;
726 bi->bi_entry_get_rw = bdb_entry_get;
729 * hooks for slap tools
731 bi->bi_tool_entry_open = bdb_tool_entry_open;
732 bi->bi_tool_entry_close = bdb_tool_entry_close;
733 bi->bi_tool_entry_first = bdb_tool_entry_next;
734 bi->bi_tool_entry_next = bdb_tool_entry_next;
735 bi->bi_tool_entry_get = bdb_tool_entry_get;
736 bi->bi_tool_entry_put = bdb_tool_entry_put;
737 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
738 bi->bi_tool_sync = 0;
739 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
740 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
741 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
743 bi->bi_connection_init = 0;
744 bi->bi_connection_destroy = 0;
746 rc = bdb_back_init_cf( bi );
751 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
752 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
754 /* conditionally define the init_module() function */
756 SLAP_BACKEND_INIT_MODULE( hdb )
757 #else /* !BDB_HIER */
758 SLAP_BACKEND_INIT_MODULE( bdb )
759 #endif /* !BDB_HIER */
761 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */