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>
27 #endif /* HAVE_UTIME_H */
33 static const struct bdbi_database {
38 } bdbi_databases[] = {
39 { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
40 { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
44 typedef void * db_malloc(size_t);
45 typedef void * db_realloc(void *, size_t);
48 bdb_db_init( BackendDB *be )
52 Debug( LDAP_DEBUG_TRACE,
53 LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
56 /* allocate backend-database-specific stuff */
57 bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
59 /* DBEnv parameters */
60 bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
61 bdb->bi_dbenv_xflags = 0;
62 bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
64 bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
66 bdb->bi_lock_detect = DB_LOCK_DEFAULT;
67 bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
68 bdb->bi_search_stack = NULL;
70 ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
71 ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
73 ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex );
75 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
76 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
77 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
78 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
79 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
82 be->be_cf_ocs = be->bd_info->bi_cf_ocs;
88 * Unconditionally perform a database recovery. Only works on
89 * databases that were previously opened with transactions and
93 bdb_do_recovery( BackendDB *be )
95 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
99 char path[MAXPATHLEN], *ptr;
101 /* Create and init the recovery environment */
102 rc = db_env_create( &re_dbenv, 0 );
104 Debug( LDAP_DEBUG_ANY,
105 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
106 db_strerror(rc), rc, 0 );
109 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
110 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
111 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
112 #if DB_VERSION_FULL < 0x04030000
113 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
115 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
118 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
119 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
121 /* If a key was set, use shared memory for the BDB environment */
122 if ( bdb->bi_shm_key ) {
123 re_dbenv->set_shm_key( re_dbenv, bdb->bi_shm_key );
124 flags |= DB_SYSTEM_MEM;
127 /* Open the environment, which will also perform the recovery */
129 strcpy( path, bdb->bi_dbenv_home );
131 rc = re_dbenv->open( re_dbenv,
134 bdb->bi_dbenv_mode );
136 rc = re_dbenv->open( re_dbenv,
139 bdb->bi_dbenv_mode );
142 Debug( LDAP_DEBUG_ANY,
143 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
144 db_strerror(rc), rc, 0 );
147 (void) re_dbenv->close( re_dbenv, 0 );
149 /* By convention we reset the mtime for id2entry.bdb to the current time */
150 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
151 *ptr++ = LDAP_DIRSEP[0];
152 strcpy( ptr, bdbi_databases[0].file);
153 (void) utime( path, NULL);
159 * Database recovery logic:
160 * This function is called whenever the database appears to have been
161 * shut down uncleanly, as determined by the alock functions.
162 * Because of the -q function in slapadd, there is also the possibility
163 * that the shutdown happened when transactions weren't being used and
164 * the database is likely to be corrupt. The function checks for this
165 * condition by examining the environment to make sure it had previously
166 * been opened with transactions enabled. If this is the case, the
167 * database is recovered as usual. If transactions were not enabled,
168 * then this function will return a fail.
171 bdb_db_recover( BackendDB *be )
173 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
178 char path[MAXPATHLEN];
181 /* Create the recovery environment, then open it.
182 * We use the DB_JOIN in combination with a flags value of
183 * zero so we join an existing environment and can read the
184 * value of the flags that were used the last time the
185 * environment was opened. DB_CREATE is added because the
186 * open would fail if the only thing that had been done
187 * was an open with transactions and logs disabled.
189 rc = db_env_create( &re_dbenv, 0 );
191 Debug( LDAP_DEBUG_ANY,
192 "bdb_db_recover: db_env_create failed: %s (%d)\n",
193 db_strerror(rc), rc, 0 );
196 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
197 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
199 Debug( LDAP_DEBUG_TRACE,
200 "bdb_db_recover: dbenv_open(%s)\n",
201 bdb->bi_dbenv_home, 0, 0);
204 strcpy( path, bdb->bi_dbenv_home );
206 rc = re_dbenv->open( re_dbenv,
209 bdb->bi_dbenv_mode );
211 rc = re_dbenv->open( re_dbenv,
214 bdb->bi_dbenv_mode );
218 Debug( LDAP_DEBUG_TRACE,
219 "bdb_db_recover: DB environment files are missing, assuming it was "
220 "manually recovered\n", 0, 0, 0 );
224 Debug( LDAP_DEBUG_ANY,
225 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
226 db_strerror(rc), rc, 0 );
231 * Check the flags that had been used in the previous open.
232 * The environment needed to have had both
233 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
234 * recover the database. Otherwise the an app failed while running
235 * without transactions and logs enabled and the dn2id and id2entry
236 * mapping is likely to be corrupt.
238 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
240 Debug( LDAP_DEBUG_ANY,
241 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
242 db_strerror(rc), rc, 0 );
246 (void) re_dbenv->close( re_dbenv, 0 );
248 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
249 return bdb_do_recovery( be );
252 Debug( LDAP_DEBUG_ANY,
253 "bdb_db_recover: Database cannot be recovered. "\
254 "Restore from backup!\n", 0, 0, 0);
261 bdb_db_open( BackendDB *be )
264 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
265 struct stat stat1, stat2;
267 char path[MAXPATHLEN];
270 Debug( LDAP_DEBUG_ARGS,
272 be->be_suffix[0].bv_val, 0, 0 );
274 #ifndef BDB_MULTIPLE_SUFFIXES
275 if ( be->be_suffix[1].bv_val ) {
276 Debug( LDAP_DEBUG_ANY,
277 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
282 /* Check existence of dbenv_home. Any error means trouble */
283 rc = stat( bdb->bi_dbenv_home, &stat1 );
285 Debug( LDAP_DEBUG_ANY,
286 "bdb_db_open: Cannot access database directory %s (%d)\n",
287 bdb->bi_dbenv_home, errno, 0 );
291 /* Perform database use arbitration/recovery logic */
292 rc = alock_open( &bdb->bi_alock_info,
295 slapMode & SLAP_TOOL_READONLY ?
296 ALOCK_LOCKED : ALOCK_UNIQUE );
298 if( rc == ALOCK_RECOVER ) {
299 Debug( LDAP_DEBUG_ANY,
300 "bdb_db_open: unclean shutdown detected;"
301 " attempting recovery.\n",
303 if( bdb_db_recover( be ) != 0 ) {
304 Debug( LDAP_DEBUG_ANY,
305 "bdb_db_open: DB recovery failed.\n",
309 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
310 Debug( LDAP_DEBUG_ANY,
311 "bdb_db_open: alock_recover failed\n",
316 } else if( rc == ALOCK_BUSY ) {
317 Debug( LDAP_DEBUG_ANY,
318 "bdb_db_open: database already in use\n",
321 } else if( rc != ALOCK_CLEAN ) {
322 Debug( LDAP_DEBUG_ANY,
323 "bdb_db_open: alock package is unstable\n",
329 * The DB_CONFIG file may have changed. If so, recover the
330 * database so that new settings are put into effect. Also
331 * note the possible absence of DB_CONFIG in the log.
333 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
334 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
335 *ptr++ = LDAP_DIRSEP[0];
336 strcpy( ptr, bdbi_databases[0].file);
337 if( stat( path, &stat2 ) == 0 ) {
338 if( stat2.st_mtime <= stat1.st_mtime ) {
339 Debug( LDAP_DEBUG_ANY,
340 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
341 "Performing database recovery to activate new settings.\n",
342 be->be_suffix[0].bv_val, 0, 0 );
343 if( bdb_do_recovery( be ) != 0) {
344 Debug( LDAP_DEBUG_ANY,
345 "bdb_db_open: db recovery failed.\n",
354 Debug( LDAP_DEBUG_ANY,
355 "bdb_db_open: Warning - No DB_CONFIG file found "
356 "in directory %s: (%d)\n"
357 "Expect poor performance for suffix %s.\n",
358 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
361 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
362 if ( !( slapMode & SLAP_TOOL_QUICK ))
363 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
365 rc = db_env_create( &bdb->bi_dbenv, 0 );
367 Debug( LDAP_DEBUG_ANY,
368 "bdb_db_open: db_env_create failed: %s (%d)\n",
369 db_strerror(rc), rc, 0 );
373 /* If a key was set, use shared memory for the BDB environment */
374 if ( bdb->bi_shm_key ) {
375 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
376 flags |= DB_SYSTEM_MEM;
379 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
380 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
381 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
383 /* One long-lived TXN per thread, two TXNs per write op */
384 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
386 #ifdef SLAP_ZONE_ALLOC
387 if ( bdb->bi_cache.c_maxsize ) {
388 bdb->bi_cache.c_zctx = slap_zn_mem_create(
396 if ( bdb->bi_idl_cache_max_size ) {
397 bdb->bi_idl_tree = NULL;
398 bdb->bi_idl_cache_size = 0;
401 if( bdb->bi_dbenv_xflags != 0 ) {
402 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
403 bdb->bi_dbenv_xflags, 1);
405 Debug( LDAP_DEBUG_ANY,
406 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
407 db_strerror(rc), rc, 0 );
412 Debug( LDAP_DEBUG_TRACE,
413 "bdb_db_open: dbenv_open(%s)\n",
414 bdb->bi_dbenv_home, 0, 0);
417 strcpy( path, bdb->bi_dbenv_home );
419 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
422 bdb->bi_dbenv_mode );
424 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
427 bdb->bi_dbenv_mode );
430 Debug( LDAP_DEBUG_ANY,
431 "bdb_db_open: dbenv_open failed: %s (%d)\n",
432 db_strerror(rc), rc, 0 );
436 flags = DB_THREAD | bdb->bi_db_opflags;
438 #ifdef DB_AUTO_COMMIT
439 if ( !( slapMode & SLAP_TOOL_QUICK ))
440 flags |= DB_AUTO_COMMIT;
443 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
444 BDB_INDICES * sizeof(struct bdb_db_info *) );
446 /* open (and create) main database */
447 for( i = 0; bdbi_databases[i].name; i++ ) {
448 struct bdb_db_info *db;
450 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
452 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
454 Debug( LDAP_DEBUG_ANY,
455 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
456 bdb->bi_dbenv_home, db_strerror(rc), rc );
460 if( i == BDB_ID2ENTRY ) {
461 rc = db->bdi_db->set_pagesize( db->bdi_db,
462 BDB_ID2ENTRY_PAGESIZE );
463 if ( slapMode & SLAP_TOOL_READMAIN ) {
469 rc = db->bdi_db->set_flags( db->bdi_db,
470 DB_DUP | DB_DUPSORT );
472 if ( slapMode & SLAP_TOOL_READONLY ) {
478 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
484 rc = db->bdi_db->set_pagesize( db->bdi_db,
489 strcpy( path, bdbi_databases[i].file );
491 rc = DB_OPEN( db->bdi_db,
493 /* bdbi_databases[i].name, */ NULL,
494 bdbi_databases[i].type,
495 bdbi_databases[i].flags | flags,
496 bdb->bi_dbenv_mode );
498 rc = DB_OPEN( db->bdi_db,
499 bdbi_databases[i].file,
500 /* bdbi_databases[i].name, */ NULL,
501 bdbi_databases[i].type,
502 bdbi_databases[i].flags | flags,
503 bdb->bi_dbenv_mode );
507 char buf[SLAP_TEXT_BUFLEN];
509 snprintf( buf, sizeof(buf), "%s/%s",
510 bdb->bi_dbenv_home, bdbi_databases[i].file );
511 Debug( LDAP_DEBUG_ANY,
512 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
513 buf, db_strerror(rc), rc );
517 flags &= ~(DB_CREATE | DB_RDONLY);
518 db->bdi_name = bdbi_databases[i].name;
519 bdb->bi_databases[i] = db;
522 bdb->bi_databases[i] = NULL;
523 bdb->bi_ndatabases = i;
526 rc = bdb_last_id( be, NULL );
528 Debug( LDAP_DEBUG_ANY,
529 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
530 bdb->bi_dbenv_home, db_strerror(rc), rc );
534 if ( !( slapMode & SLAP_TOOL_QUICK )) {
535 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
538 bdb->bi_flags |= BDB_IS_OPEN;
544 bdb_db_close( BackendDB *be )
547 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
548 struct bdb_db_info *db;
549 bdb_idl_cache_entry_t *entry, *next_entry;
551 /* backend_shutdown closes everything, even if not all were opened */
552 if ( !( bdb->bi_flags & BDB_IS_OPEN ))
555 bdb->bi_flags &= ~BDB_IS_OPEN;
557 ber_bvarray_free( bdb->bi_db_config );
558 bdb->bi_db_config = NULL;
560 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
561 db = bdb->bi_databases[bdb->bi_ndatabases];
562 rc = db->bdi_db->close( db->bdi_db, 0 );
563 /* Lower numbered names are not strdup'd */
564 if( bdb->bi_ndatabases >= BDB_NDB )
565 free( db->bdi_name );
568 free( bdb->bi_databases );
569 bdb->bi_databases = NULL;
571 bdb_cache_release_all (&bdb->bi_cache);
573 if ( bdb->bi_idl_cache_max_size ) {
574 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
575 avl_free( bdb->bi_idl_tree, NULL );
576 bdb->bi_idl_tree = NULL;
577 entry = bdb->bi_idl_lru_head;
578 while ( entry != NULL ) {
579 next_entry = entry->idl_lru_next;
582 free( entry->kstr.bv_val );
586 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
587 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
590 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
591 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
592 bdb->bi_cache.c_locker = 0;
595 /* close db environment */
596 if( bdb->bi_dbenv ) {
597 /* force a checkpoint, but not if we were ReadOnly,
598 * and not in Quick mode since there are no transactions there.
600 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
601 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
603 Debug( LDAP_DEBUG_ANY,
604 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
605 db_strerror(rc), rc, 0 );
609 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
610 bdb->bi_dbenv = NULL;
612 Debug( LDAP_DEBUG_ANY,
613 "bdb_db_close: close failed: %s (%d)\n",
614 db_strerror(rc), rc, 0 );
618 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2
619 /* Delete the environment if we were in quick mode. This
620 * works around a bug in bdb4.2 that interferes with the
621 * operation of db_stat and other tools after a slapadd -q
622 * or slapindex -q has taken place.
624 if( slapMode & SLAP_TOOL_QUICK ) {
625 rc = db_env_create( &bdb->bi_dbenv, 0 );
627 Debug( LDAP_DEBUG_ANY,
628 "bdb_db_close: db_env_create failed: %s (%d)\n",
629 db_strerror(rc), rc, 0 );
632 rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home,
634 bdb->bi_dbenv = NULL;
636 Debug( LDAP_DEBUG_ANY,
637 "bdb_db_close: dbenv_remove failed: %s (%d)\n",
638 db_strerror(rc), rc, 0 );
645 rc = alock_close( &bdb->bi_alock_info );
647 Debug( LDAP_DEBUG_ANY,
648 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
656 bdb_db_destroy( BackendDB *be )
658 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
660 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
661 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
663 bdb_attr_index_destroy( bdb->bi_attrs );
665 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
666 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
667 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
669 ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
671 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
672 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
673 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
674 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
677 be->be_private = NULL;
688 static char *controls[] = {
690 LDAP_CONTROL_MANAGEDSAIT,
692 LDAP_CONTROL_PAGEDRESULTS,
693 #ifdef LDAP_CONTROL_SUBENTRIES
694 LDAP_CONTROL_SUBENTRIES,
696 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
697 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
702 /* initialize the underlying database system */
703 Debug( LDAP_DEBUG_TRACE,
704 LDAP_XSTRING(bdb_back_initialize) ": initialize "
705 BDB_UCTYPE " backend\n", 0, 0, 0 );
708 SLAP_BFLAG_INCREMENT |
709 #ifdef BDB_SUBENTRIES
710 SLAP_BFLAG_SUBENTRIES |
713 SLAP_BFLAG_REFERRALS;
715 bi->bi_controls = controls;
717 { /* version check */
718 int major, minor, patch, ver;
719 char *version = db_version( &major, &minor, &patch );
723 /* All our stdio does an ASCII to EBCDIC conversion on
724 * the output. Strings from the BDB library are already
725 * in EBCDIC; we have to go back and forth...
727 strcpy( v2, version );
732 ver = (major << 24) | (minor << 16) | patch;
733 if( ver != DB_VERSION_FULL ) {
734 /* fail if a versions don't match */
735 Debug( LDAP_DEBUG_ANY,
736 LDAP_XSTRING(bdb_back_initialize) ": "
737 "BDB library version mismatch:"
738 " expected " DB_VERSION_STRING ","
739 " got %s\n", version, 0, 0 );
743 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
744 ": %s\n", version, 0, 0 );
747 db_env_set_func_free( ber_memfree );
748 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
749 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
751 /* This is a no-op on a NO_THREAD build. Leave the default
752 * alone so that BDB will sleep on interprocess conflicts.
754 db_env_set_func_yield( ldap_pvt_thread_yield );
762 bi->bi_db_init = bdb_db_init;
763 bi->bi_db_config = config_generic_wrapper;
764 bi->bi_db_open = bdb_db_open;
765 bi->bi_db_close = bdb_db_close;
766 bi->bi_db_destroy = bdb_db_destroy;
768 bi->bi_op_add = bdb_add;
769 bi->bi_op_bind = bdb_bind;
770 bi->bi_op_compare = bdb_compare;
771 bi->bi_op_delete = bdb_delete;
772 bi->bi_op_modify = bdb_modify;
773 bi->bi_op_modrdn = bdb_modrdn;
774 bi->bi_op_search = bdb_search;
776 bi->bi_op_unbind = 0;
778 bi->bi_extended = bdb_extended;
780 bi->bi_chk_referrals = bdb_referrals;
781 bi->bi_operational = bdb_operational;
782 bi->bi_has_subordinates = bdb_hasSubordinates;
783 bi->bi_entry_release_rw = bdb_entry_release;
784 bi->bi_entry_get_rw = bdb_entry_get;
787 * hooks for slap tools
789 bi->bi_tool_entry_open = bdb_tool_entry_open;
790 bi->bi_tool_entry_close = bdb_tool_entry_close;
791 bi->bi_tool_entry_first = bdb_tool_entry_next;
792 bi->bi_tool_entry_next = bdb_tool_entry_next;
793 bi->bi_tool_entry_get = bdb_tool_entry_get;
794 bi->bi_tool_entry_put = bdb_tool_entry_put;
795 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
796 bi->bi_tool_sync = 0;
797 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
798 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
799 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
801 bi->bi_connection_init = 0;
802 bi->bi_connection_destroy = 0;
804 rc = bdb_back_init_cf( bi );
809 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
810 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
812 /* conditionally define the init_module() function */
814 SLAP_BACKEND_INIT_MODULE( hdb )
815 #else /* !BDB_HIER */
816 SLAP_BACKEND_INIT_MODULE( bdb )
817 #endif /* !BDB_HIER */
819 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */