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 * Unconditionally perform a database recovery. Only works on
92 * databases that were previously opened with transactions and
96 bdb_do_recovery( BackendDB *be )
98 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
102 char path[MAXPATHLEN], *ptr;
104 /* Create and init the recovery environment */
105 rc = db_env_create( &re_dbenv, 0 );
107 Debug( LDAP_DEBUG_ANY,
108 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
109 db_strerror(rc), rc, 0 );
112 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
113 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
114 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
115 #if DB_VERSION_FULL < 0x04030000
116 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
118 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
121 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
122 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
124 /* If a key was set, use shared memory for the BDB environment */
125 if ( bdb->bi_shm_key ) {
126 re_dbenv->set_shm_key( re_dbenv, bdb->bi_shm_key );
127 flags |= DB_SYSTEM_MEM;
130 /* Open the environment, which will also perform the recovery */
132 strcpy( path, bdb->bi_dbenv_home );
134 rc = re_dbenv->open( re_dbenv,
137 bdb->bi_dbenv_mode );
139 rc = re_dbenv->open( re_dbenv,
142 bdb->bi_dbenv_mode );
145 Debug( LDAP_DEBUG_ANY,
146 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
147 db_strerror(rc), rc, 0 );
150 (void) re_dbenv->close( re_dbenv, 0 );
152 /* By convention we reset the mtime for id2entry.bdb to the current time */
153 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
154 *ptr++ = LDAP_DIRSEP[0];
155 strcpy( ptr, bdbi_databases[0].file);
156 (void) utime( path, NULL);
162 * Database recovery logic:
163 * This function is called whenever the database appears to have been
164 * shut down uncleanly, as determined by the alock functions.
165 * Because of the -q function in slapadd, there is also the possibility
166 * that the shutdown happened when transactions weren't being used and
167 * the database is likely to be corrupt. The function checks for this
168 * condition by examining the environment to make sure it had previously
169 * been opened with transactions enabled. If this is the case, the
170 * database is recovered as usual. If transactions were not enabled,
171 * then this function will return a fail.
174 bdb_db_recover( BackendDB *be )
176 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
181 char path[MAXPATHLEN];
184 /* Create the recovery environment, then open it.
185 * We use the DB_JOIN in combination with a flags value of
186 * zero so we join an existing environment and can read the
187 * value of the flags that were used the last time the
188 * environment was opened. DB_CREATE is added because the
189 * open would fail if the only thing that had been done
190 * was an open with transactions and logs disabled.
192 rc = db_env_create( &re_dbenv, 0 );
194 Debug( LDAP_DEBUG_ANY,
195 "bdb_db_recover: db_env_create failed: %s (%d)\n",
196 db_strerror(rc), rc, 0 );
199 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
200 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
202 Debug( LDAP_DEBUG_TRACE,
203 "bdb_db_recover: dbenv_open(%s)\n",
204 bdb->bi_dbenv_home, 0, 0);
207 strcpy( path, bdb->bi_dbenv_home );
209 rc = re_dbenv->open( re_dbenv,
212 bdb->bi_dbenv_mode );
214 rc = re_dbenv->open( re_dbenv,
217 bdb->bi_dbenv_mode );
221 Debug( LDAP_DEBUG_TRACE,
222 "bdb_db_recover: DB environment files are missing, assuming it was "
223 "manually recovered\n", 0, 0, 0 );
227 Debug( LDAP_DEBUG_ANY,
228 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
229 db_strerror(rc), rc, 0 );
234 * Check the flags that had been used in the previous open.
235 * The environment needed to have had both
236 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
237 * recover the database. Otherwise the an app failed while running
238 * without transactions and logs enabled and the dn2id and id2entry
239 * mapping is likely to be corrupt.
241 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
243 Debug( LDAP_DEBUG_ANY,
244 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
245 db_strerror(rc), rc, 0 );
249 (void) re_dbenv->close( re_dbenv, 0 );
251 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
252 return bdb_do_recovery( be );
255 Debug( LDAP_DEBUG_ANY,
256 "bdb_db_recover: Database cannot be recovered. "\
257 "Restore from backup!\n", 0, 0, 0);
264 bdb_db_open( BackendDB *be )
267 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
268 struct stat stat1, stat2;
270 char path[MAXPATHLEN];
273 if ( be->be_suffix == NULL ) {
274 Debug( LDAP_DEBUG_ANY,
275 "bdb_db_open: need suffix\n",
280 Debug( LDAP_DEBUG_ARGS,
282 be->be_suffix[0].bv_val, 0, 0 );
284 #ifndef BDB_MULTIPLE_SUFFIXES
285 if ( be->be_suffix[1].bv_val ) {
286 Debug( LDAP_DEBUG_ANY,
287 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
292 /* Check existence of dbenv_home. Any error means trouble */
293 rc = stat( bdb->bi_dbenv_home, &stat1 );
295 Debug( LDAP_DEBUG_ANY,
296 "bdb_db_open: Cannot access database directory %s (%d)\n",
297 bdb->bi_dbenv_home, errno, 0 );
301 /* Perform database use arbitration/recovery logic */
302 rc = alock_open( &bdb->bi_alock_info,
305 slapMode & SLAP_TOOL_READONLY ?
306 ALOCK_LOCKED : ALOCK_UNIQUE );
308 if( rc == ALOCK_RECOVER ) {
309 Debug( LDAP_DEBUG_ANY,
310 "bdb_db_open: unclean shutdown detected;"
311 " attempting recovery.\n",
313 if( bdb_db_recover( be ) != 0 ) {
314 Debug( LDAP_DEBUG_ANY,
315 "bdb_db_open: DB recovery failed.\n",
319 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
320 Debug( LDAP_DEBUG_ANY,
321 "bdb_db_open: alock_recover failed\n",
326 } else if( rc == ALOCK_BUSY ) {
327 Debug( LDAP_DEBUG_ANY,
328 "bdb_db_open: database already in use\n",
331 } else if( rc != ALOCK_CLEAN ) {
332 Debug( LDAP_DEBUG_ANY,
333 "bdb_db_open: alock package is unstable\n",
339 * The DB_CONFIG file may have changed. If so, recover the
340 * database so that new settings are put into effect. Also
341 * note the possible absence of DB_CONFIG in the log.
343 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
344 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
345 *ptr++ = LDAP_DIRSEP[0];
346 strcpy( ptr, bdbi_databases[0].file);
347 if( stat( path, &stat2 ) == 0 ) {
348 if( stat2.st_mtime <= stat1.st_mtime ) {
349 Debug( LDAP_DEBUG_ANY,
350 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
351 "Performing database recovery to activate new settings.\n",
352 be->be_suffix[0].bv_val, 0, 0 );
353 if( bdb_do_recovery( be ) != 0) {
354 Debug( LDAP_DEBUG_ANY,
355 "bdb_db_open: db recovery failed.\n",
364 Debug( LDAP_DEBUG_ANY,
365 "bdb_db_open: Warning - No DB_CONFIG file found "
366 "in directory %s: (%d)\n"
367 "Expect poor performance for suffix %s.\n",
368 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
371 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
372 if ( !( slapMode & SLAP_TOOL_QUICK ))
373 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
375 rc = db_env_create( &bdb->bi_dbenv, 0 );
377 Debug( LDAP_DEBUG_ANY,
378 "bdb_db_open: db_env_create failed: %s (%d)\n",
379 db_strerror(rc), rc, 0 );
383 /* If a key was set, use shared memory for the BDB environment */
384 if ( bdb->bi_shm_key ) {
385 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
386 flags |= DB_SYSTEM_MEM;
389 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
390 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
391 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
393 /* One long-lived TXN per thread, two TXNs per write op */
394 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
396 #ifdef SLAP_ZONE_ALLOC
397 if ( bdb->bi_cache.c_maxsize ) {
398 bdb->bi_cache.c_zctx = slap_zn_mem_create(
406 if ( bdb->bi_idl_cache_max_size ) {
407 bdb->bi_idl_tree = NULL;
408 bdb->bi_idl_cache_size = 0;
411 if( bdb->bi_dbenv_xflags != 0 ) {
412 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
413 bdb->bi_dbenv_xflags, 1);
415 Debug( LDAP_DEBUG_ANY,
416 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
417 db_strerror(rc), rc, 0 );
422 Debug( LDAP_DEBUG_TRACE,
423 "bdb_db_open: dbenv_open(%s)\n",
424 bdb->bi_dbenv_home, 0, 0);
427 strcpy( path, bdb->bi_dbenv_home );
429 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
432 bdb->bi_dbenv_mode );
434 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
437 bdb->bi_dbenv_mode );
440 Debug( LDAP_DEBUG_ANY,
441 "bdb_db_open: dbenv_open failed: %s (%d)\n",
442 db_strerror(rc), rc, 0 );
446 flags = DB_THREAD | bdb->bi_db_opflags;
448 #ifdef DB_AUTO_COMMIT
449 if ( !( slapMode & SLAP_TOOL_QUICK ))
450 flags |= DB_AUTO_COMMIT;
453 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
454 BDB_INDICES * sizeof(struct bdb_db_info *) );
456 /* open (and create) main database */
457 for( i = 0; bdbi_databases[i].name; i++ ) {
458 struct bdb_db_info *db;
460 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
462 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
464 Debug( LDAP_DEBUG_ANY,
465 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
466 bdb->bi_dbenv_home, db_strerror(rc), rc );
470 if( i == BDB_ID2ENTRY ) {
471 rc = db->bdi_db->set_pagesize( db->bdi_db,
472 BDB_ID2ENTRY_PAGESIZE );
473 if ( slapMode & SLAP_TOOL_READMAIN ) {
479 rc = db->bdi_db->set_flags( db->bdi_db,
480 DB_DUP | DB_DUPSORT );
482 if ( slapMode & SLAP_TOOL_READONLY ) {
488 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
494 rc = db->bdi_db->set_pagesize( db->bdi_db,
499 strcpy( path, bdbi_databases[i].file );
501 rc = DB_OPEN( db->bdi_db,
503 /* bdbi_databases[i].name, */ NULL,
504 bdbi_databases[i].type,
505 bdbi_databases[i].flags | flags,
506 bdb->bi_dbenv_mode );
508 rc = DB_OPEN( db->bdi_db,
509 bdbi_databases[i].file,
510 /* bdbi_databases[i].name, */ NULL,
511 bdbi_databases[i].type,
512 bdbi_databases[i].flags | flags,
513 bdb->bi_dbenv_mode );
517 char buf[SLAP_TEXT_BUFLEN];
519 snprintf( buf, sizeof(buf), "%s/%s",
520 bdb->bi_dbenv_home, bdbi_databases[i].file );
521 Debug( LDAP_DEBUG_ANY,
522 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
523 buf, db_strerror(rc), rc );
527 flags &= ~(DB_CREATE | DB_RDONLY);
528 db->bdi_name = bdbi_databases[i].name;
529 bdb->bi_databases[i] = db;
532 bdb->bi_databases[i] = NULL;
533 bdb->bi_ndatabases = i;
536 rc = bdb_last_id( be, NULL );
538 Debug( LDAP_DEBUG_ANY,
539 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
540 bdb->bi_dbenv_home, db_strerror(rc), rc );
544 if ( !( slapMode & SLAP_TOOL_QUICK )) {
545 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
548 bdb->bi_flags |= BDB_IS_OPEN;
554 bdb_db_close( BackendDB *be )
557 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
558 struct bdb_db_info *db;
559 bdb_idl_cache_entry_t *entry, *next_entry;
561 /* backend_shutdown closes everything, even if not all were opened */
562 if ( !( bdb->bi_flags & BDB_IS_OPEN ))
565 bdb->bi_flags &= ~BDB_IS_OPEN;
567 ber_bvarray_free( bdb->bi_db_config );
568 bdb->bi_db_config = NULL;
570 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
571 db = bdb->bi_databases[bdb->bi_ndatabases];
572 rc = db->bdi_db->close( db->bdi_db, 0 );
573 /* Lower numbered names are not strdup'd */
574 if( bdb->bi_ndatabases >= BDB_NDB )
575 free( db->bdi_name );
578 free( bdb->bi_databases );
579 bdb->bi_databases = NULL;
581 bdb_cache_release_all (&bdb->bi_cache);
583 if ( bdb->bi_idl_cache_max_size ) {
584 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
585 avl_free( bdb->bi_idl_tree, NULL );
586 bdb->bi_idl_tree = NULL;
587 entry = bdb->bi_idl_lru_head;
588 while ( entry != NULL ) {
589 next_entry = entry->idl_lru_next;
592 free( entry->kstr.bv_val );
596 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
597 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
600 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
601 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
602 bdb->bi_cache.c_locker = 0;
605 /* close db environment */
606 if( bdb->bi_dbenv ) {
607 /* force a checkpoint, but not if we were ReadOnly,
608 * and not in Quick mode since there are no transactions there.
610 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
611 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
613 Debug( LDAP_DEBUG_ANY,
614 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
615 db_strerror(rc), rc, 0 );
619 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
620 bdb->bi_dbenv = NULL;
622 Debug( LDAP_DEBUG_ANY,
623 "bdb_db_close: close failed: %s (%d)\n",
624 db_strerror(rc), rc, 0 );
628 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2
629 /* Delete the environment if we were in quick mode. This
630 * works around a bug in bdb4.2 that interferes with the
631 * operation of db_stat and other tools after a slapadd -q
632 * or slapindex -q has taken place.
634 if( slapMode & SLAP_TOOL_QUICK ) {
635 rc = db_env_create( &bdb->bi_dbenv, 0 );
637 Debug( LDAP_DEBUG_ANY,
638 "bdb_db_close: db_env_create failed: %s (%d)\n",
639 db_strerror(rc), rc, 0 );
642 rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home,
644 bdb->bi_dbenv = NULL;
646 Debug( LDAP_DEBUG_ANY,
647 "bdb_db_close: dbenv_remove failed: %s (%d)\n",
648 db_strerror(rc), rc, 0 );
655 rc = alock_close( &bdb->bi_alock_info );
657 Debug( LDAP_DEBUG_ANY,
658 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
666 bdb_db_destroy( BackendDB *be )
668 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
670 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
671 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
673 bdb_attr_index_destroy( bdb->bi_attrs );
675 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
676 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
677 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
679 ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
681 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
682 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
683 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
684 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
687 be->be_private = NULL;
698 static char *controls[] = {
700 LDAP_CONTROL_MANAGEDSAIT,
702 LDAP_CONTROL_PAGEDRESULTS,
703 #ifdef LDAP_CONTROL_SUBENTRIES
704 LDAP_CONTROL_SUBENTRIES,
706 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
707 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
712 /* initialize the underlying database system */
713 Debug( LDAP_DEBUG_TRACE,
714 LDAP_XSTRING(bdb_back_initialize) ": initialize "
715 BDB_UCTYPE " backend\n", 0, 0, 0 );
718 SLAP_BFLAG_INCREMENT |
719 #ifdef BDB_SUBENTRIES
720 SLAP_BFLAG_SUBENTRIES |
723 SLAP_BFLAG_REFERRALS;
725 bi->bi_controls = controls;
727 { /* version check */
728 int major, minor, patch, ver;
729 char *version = db_version( &major, &minor, &patch );
733 /* All our stdio does an ASCII to EBCDIC conversion on
734 * the output. Strings from the BDB library are already
735 * in EBCDIC; we have to go back and forth...
737 strcpy( v2, version );
742 ver = (major << 24) | (minor << 16) | patch;
743 if( ver != DB_VERSION_FULL ) {
744 /* fail if a versions don't match */
745 Debug( LDAP_DEBUG_ANY,
746 LDAP_XSTRING(bdb_back_initialize) ": "
747 "BDB library version mismatch:"
748 " expected " DB_VERSION_STRING ","
749 " got %s\n", version, 0, 0 );
753 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
754 ": %s\n", version, 0, 0 );
757 db_env_set_func_free( ber_memfree );
758 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
759 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
761 /* This is a no-op on a NO_THREAD build. Leave the default
762 * alone so that BDB will sleep on interprocess conflicts.
764 db_env_set_func_yield( ldap_pvt_thread_yield );
772 bi->bi_db_init = bdb_db_init;
773 bi->bi_db_config = config_generic_wrapper;
774 bi->bi_db_open = bdb_db_open;
775 bi->bi_db_close = bdb_db_close;
776 bi->bi_db_destroy = bdb_db_destroy;
778 bi->bi_op_add = bdb_add;
779 bi->bi_op_bind = bdb_bind;
780 bi->bi_op_compare = bdb_compare;
781 bi->bi_op_delete = bdb_delete;
782 bi->bi_op_modify = bdb_modify;
783 bi->bi_op_modrdn = bdb_modrdn;
784 bi->bi_op_search = bdb_search;
786 bi->bi_op_unbind = 0;
788 bi->bi_extended = bdb_extended;
790 bi->bi_chk_referrals = bdb_referrals;
791 bi->bi_operational = bdb_operational;
792 bi->bi_has_subordinates = bdb_hasSubordinates;
793 bi->bi_entry_release_rw = bdb_entry_release;
794 bi->bi_entry_get_rw = bdb_entry_get;
797 * hooks for slap tools
799 bi->bi_tool_entry_open = bdb_tool_entry_open;
800 bi->bi_tool_entry_close = bdb_tool_entry_close;
801 bi->bi_tool_entry_first = bdb_tool_entry_next;
802 bi->bi_tool_entry_next = bdb_tool_entry_next;
803 bi->bi_tool_entry_get = bdb_tool_entry_get;
804 bi->bi_tool_entry_put = bdb_tool_entry_put;
805 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
806 bi->bi_tool_sync = 0;
807 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
808 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
809 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
811 bi->bi_connection_init = 0;
812 bi->bi_connection_destroy = 0;
814 rc = bdb_back_init_cf( bi );
819 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
820 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
822 /* conditionally define the init_module() function */
824 SLAP_BACKEND_INIT_MODULE( hdb )
825 #else /* !BDB_HIER */
826 SLAP_BACKEND_INIT_MODULE( bdb )
827 #endif /* !BDB_HIER */
829 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */