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 );
70 ldap_pvt_thread_mutex_init( &bdb->bi_modrdns_mutex );
72 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
73 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
74 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
75 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
76 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
79 be->be_cf_ocs = be->bd_info->bi_cf_ocs;
85 * Unconditionally perform a database recovery. Only works on
86 * databases that were previously opened with transactions and
90 bdb_do_recovery( BackendDB *be )
92 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
96 char path[MAXPATHLEN], *ptr;
98 /* Create and init the recovery environment */
99 rc = db_env_create( &re_dbenv, 0 );
101 Debug( LDAP_DEBUG_ANY,
102 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
103 db_strerror(rc), rc, 0 );
106 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
107 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
108 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
109 #if DB_VERSION_FULL < 0x04030000
110 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
112 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
115 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
116 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
118 /* If a key was set, use shared memory for the BDB environment */
119 if ( bdb->bi_shm_key ) {
120 re_dbenv->set_shm_key( re_dbenv, bdb->bi_shm_key );
121 flags |= DB_SYSTEM_MEM;
124 /* Open the environment, which will also perform the recovery */
126 strcpy( path, bdb->bi_dbenv_home );
128 rc = re_dbenv->open( re_dbenv,
131 bdb->bi_dbenv_mode );
133 rc = re_dbenv->open( re_dbenv,
136 bdb->bi_dbenv_mode );
139 Debug( LDAP_DEBUG_ANY,
140 "bdb_do_recovery: dbenv_open failed: %s (%d)\n",
141 db_strerror(rc), rc, 0 );
144 (void) re_dbenv->close( re_dbenv, 0 );
146 /* By convention we reset the mtime for id2entry.bdb to the current time */
147 ptr = lutil_strcopy( path, bdb->bi_dbenv_home);
148 *ptr++ = LDAP_DIRSEP[0];
149 strcpy( ptr, bdbi_databases[0].file);
150 (void) utime( path, NULL);
156 * Database recovery logic:
157 * This function is called whenever the database appears to have been
158 * shut down uncleanly, as determined by the alock functions.
159 * Because of the -q function in slapadd, there is also the possibility
160 * that the shutdown happened when transactions weren't being used and
161 * the database is likely to be corrupt. The function checks for this
162 * condition by examining the environment to make sure it had previously
163 * been opened with transactions enabled. If this is the case, the
164 * database is recovered as usual. If transactions were not enabled,
165 * then this function will return a fail.
168 bdb_db_recover( BackendDB *be )
170 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
175 char path[MAXPATHLEN];
178 /* Create the recovery environment, then open it.
179 * We use the DB_JOIN in combination with a flags value of
180 * zero so we join an existing environment and can read the
181 * value of the flags that were used the last time the
182 * environment was opened. DB_CREATE is added because the
183 * open would fail if the only thing that had been done
184 * was an open with transactions and logs disabled.
186 rc = db_env_create( &re_dbenv, 0 );
188 Debug( LDAP_DEBUG_ANY,
189 "bdb_db_recover: db_env_create failed: %s (%d)\n",
190 db_strerror(rc), rc, 0 );
193 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
194 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
196 Debug( LDAP_DEBUG_TRACE,
197 "bdb_db_recover: dbenv_open(%s)\n",
198 bdb->bi_dbenv_home, 0, 0);
201 strcpy( path, bdb->bi_dbenv_home );
203 rc = re_dbenv->open( re_dbenv,
206 bdb->bi_dbenv_mode );
208 rc = re_dbenv->open( re_dbenv,
211 bdb->bi_dbenv_mode );
215 Debug( LDAP_DEBUG_TRACE,
216 "bdb_db_recover: DB environment files are missing, assuming it was "
217 "manually recovered\n", 0, 0, 0 );
221 Debug( LDAP_DEBUG_ANY,
222 "bdb_db_recover: dbenv_open failed: %s (%d)\n",
223 db_strerror(rc), rc, 0 );
228 * Check the flags that had been used in the previous open.
229 * The environment needed to have had both
230 * DB_INIT_LOG and DB_INIT_TXN set for us to be willing to
231 * recover the database. Otherwise the an app failed while running
232 * without transactions and logs enabled and the dn2id and id2entry
233 * mapping is likely to be corrupt.
235 rc = re_dbenv->get_open_flags( re_dbenv, &flags );
237 Debug( LDAP_DEBUG_ANY,
238 "bdb_db_recover: get_open_flags failed: %s (%d)\n",
239 db_strerror(rc), rc, 0 );
243 (void) re_dbenv->close( re_dbenv, 0 );
245 if( (flags & DB_INIT_LOG) && (flags & DB_INIT_TXN) ) {
246 return bdb_do_recovery( be );
250 Debug( LDAP_DEBUG_ANY,
251 "bdb_db_recover: Database cannot be recovered. "\
252 "Restore from backup!\n", 0, 0, 0);
259 bdb_db_open( BackendDB *be )
262 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
263 struct stat stat1, stat2;
265 char path[MAXPATHLEN];
268 Debug( LDAP_DEBUG_ARGS,
270 be->be_suffix[0].bv_val, 0, 0 );
272 #ifndef BDB_MULTIPLE_SUFFIXES
273 if ( be->be_suffix[1].bv_val ) {
274 Debug( LDAP_DEBUG_ANY,
275 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
280 /* Check existence of dbenv_home. Any error means trouble */
281 rc = stat( bdb->bi_dbenv_home, &stat1 );
283 Debug( LDAP_DEBUG_ANY,
284 "bdb_db_open: Cannot access database directory %s (%d)\n",
285 bdb->bi_dbenv_home, errno, 0 );
289 /* Perform database use arbitration/recovery logic */
290 rc = alock_open( &bdb->bi_alock_info,
293 slapMode & SLAP_TOOL_READONLY ?
294 ALOCK_LOCKED : ALOCK_UNIQUE );
296 if( rc == ALOCK_RECOVER ) {
297 Debug( LDAP_DEBUG_ANY,
298 "bdb_db_open: unclean shutdown detected;"
299 " attempting recovery.\n",
301 if( bdb_db_recover( be ) != 0 ) {
302 Debug( LDAP_DEBUG_ANY,
303 "bdb_db_open: DB recovery failed.\n",
307 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
308 Debug( LDAP_DEBUG_ANY,
309 "bdb_db_open: alock_recover failed\n",
314 } else if( rc == ALOCK_BUSY ) {
315 Debug( LDAP_DEBUG_ANY,
316 "bdb_db_open: database already in use\n",
319 } else if( rc != ALOCK_CLEAN ) {
320 Debug( LDAP_DEBUG_ANY,
321 "bdb_db_open: alock package is unstable\n",
327 * The DB_CONFIG file may have changed. If so, recover the
328 * database so that new settings are put into effect. Also
329 * note the possible absence of DB_CONFIG in the log.
331 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
332 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
333 *ptr++ = LDAP_DIRSEP[0];
334 strcpy( ptr, bdbi_databases[0].file);
335 if( stat( path, &stat2 ) == 0 ) {
336 if( stat2.st_mtime <= stat1.st_mtime ) {
337 Debug( LDAP_DEBUG_ANY,
338 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
339 "Performing database recovery to activate new settings.\n",
340 be->be_suffix[0].bv_val, 0, 0 );
341 if( bdb_do_recovery( be ) != 0) {
342 Debug( LDAP_DEBUG_ANY,
343 "bdb_db_open: db recovery failed.\n",
352 Debug( LDAP_DEBUG_ANY,
353 "bdb_db_open: Warning - No DB_CONFIG file found "
354 "in directory %s: (%d)\n"
355 "Expect poor performance for suffix %s.\n",
356 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
359 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
360 if ( !( slapMode & SLAP_TOOL_QUICK ))
361 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
363 rc = db_env_create( &bdb->bi_dbenv, 0 );
365 Debug( LDAP_DEBUG_ANY,
366 "bdb_db_open: db_env_create failed: %s (%d)\n",
367 db_strerror(rc), rc, 0 );
371 /* If a key was set, use shared memory for the BDB environment */
372 if ( bdb->bi_shm_key ) {
373 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
374 flags |= DB_SYSTEM_MEM;
377 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
378 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
379 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
381 /* One long-lived TXN per thread, two TXNs per write op */
382 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
384 #ifdef SLAP_ZONE_ALLOC
385 if ( bdb->bi_cache.c_maxsize ) {
386 bdb->bi_cache.c_zctx = slap_zn_mem_create(
394 if ( bdb->bi_idl_cache_max_size ) {
395 bdb->bi_idl_tree = NULL;
396 bdb->bi_idl_cache_size = 0;
399 if( bdb->bi_dbenv_xflags != 0 ) {
400 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
401 bdb->bi_dbenv_xflags, 1);
403 Debug( LDAP_DEBUG_ANY,
404 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
405 db_strerror(rc), rc, 0 );
410 Debug( LDAP_DEBUG_TRACE,
411 "bdb_db_open: dbenv_open(%s)\n",
412 bdb->bi_dbenv_home, 0, 0);
415 strcpy( path, bdb->bi_dbenv_home );
417 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
420 bdb->bi_dbenv_mode );
422 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
425 bdb->bi_dbenv_mode );
428 Debug( LDAP_DEBUG_ANY,
429 "bdb_db_open: dbenv_open failed: %s (%d)\n",
430 db_strerror(rc), rc, 0 );
434 flags = DB_THREAD | bdb->bi_db_opflags;
436 #ifdef DB_AUTO_COMMIT
437 if ( !( slapMode & SLAP_TOOL_QUICK ))
438 flags |= DB_AUTO_COMMIT;
441 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
442 BDB_INDICES * sizeof(struct bdb_db_info *) );
444 /* open (and create) main database */
445 for( i = 0; bdbi_databases[i].name; i++ ) {
446 struct bdb_db_info *db;
448 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
450 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
452 Debug( LDAP_DEBUG_ANY,
453 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
454 bdb->bi_dbenv_home, db_strerror(rc), rc );
458 if( i == BDB_ID2ENTRY ) {
459 rc = db->bdi_db->set_pagesize( db->bdi_db,
460 BDB_ID2ENTRY_PAGESIZE );
461 if ( slapMode & SLAP_TOOL_READMAIN ) {
467 rc = db->bdi_db->set_flags( db->bdi_db,
468 DB_DUP | DB_DUPSORT );
470 if ( slapMode & SLAP_TOOL_READONLY ) {
476 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
482 rc = db->bdi_db->set_pagesize( db->bdi_db,
487 strcpy( path, bdbi_databases[i].file );
489 rc = DB_OPEN( db->bdi_db,
491 /* bdbi_databases[i].name, */ NULL,
492 bdbi_databases[i].type,
493 bdbi_databases[i].flags | flags,
494 bdb->bi_dbenv_mode );
496 rc = DB_OPEN( db->bdi_db,
497 bdbi_databases[i].file,
498 /* bdbi_databases[i].name, */ NULL,
499 bdbi_databases[i].type,
500 bdbi_databases[i].flags | flags,
501 bdb->bi_dbenv_mode );
505 char buf[SLAP_TEXT_BUFLEN];
507 snprintf( buf, sizeof(buf), "%s/%s",
508 bdb->bi_dbenv_home, bdbi_databases[i].file );
509 Debug( LDAP_DEBUG_ANY,
510 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
511 buf, db_strerror(rc), rc );
515 flags &= ~(DB_CREATE | DB_RDONLY);
516 db->bdi_name = bdbi_databases[i].name;
517 bdb->bi_databases[i] = db;
520 bdb->bi_databases[i] = NULL;
521 bdb->bi_ndatabases = i;
524 rc = bdb_last_id( be, NULL );
526 Debug( LDAP_DEBUG_ANY,
527 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
528 bdb->bi_dbenv_home, db_strerror(rc), rc );
532 if ( !( slapMode & SLAP_TOOL_QUICK )) {
533 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
536 bdb->bi_flags |= BDB_IS_OPEN;
542 bdb_db_close( BackendDB *be )
545 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
546 struct bdb_db_info *db;
547 bdb_idl_cache_entry_t *entry, *next_entry;
549 /* backend_shutdown closes everything, even if not all were opened */
550 if ( !bdb->bi_flags & BDB_IS_OPEN )
553 bdb->bi_flags &= ~BDB_IS_OPEN;
555 ber_bvarray_free( bdb->bi_db_config );
556 bdb->bi_db_config = NULL;
558 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
559 db = bdb->bi_databases[bdb->bi_ndatabases];
560 rc = db->bdi_db->close( db->bdi_db, 0 );
561 /* Lower numbered names are not strdup'd */
562 if( bdb->bi_ndatabases >= BDB_NDB )
563 free( db->bdi_name );
566 free( bdb->bi_databases );
567 bdb->bi_databases = NULL;
569 bdb_cache_release_all (&bdb->bi_cache);
571 if ( bdb->bi_idl_cache_max_size ) {
572 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
573 avl_free( bdb->bi_idl_tree, NULL );
574 bdb->bi_idl_tree = NULL;
575 entry = bdb->bi_idl_lru_head;
576 while ( entry != NULL ) {
577 next_entry = entry->idl_lru_next;
580 free( entry->kstr.bv_val );
584 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
585 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
588 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
589 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
590 bdb->bi_cache.c_locker = 0;
593 /* close db environment */
594 if( bdb->bi_dbenv ) {
595 /* force a checkpoint, but not if we were ReadOnly,
596 * and not in Quick mode since there are no transactions there.
598 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
599 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
601 Debug( LDAP_DEBUG_ANY,
602 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
603 db_strerror(rc), rc, 0 );
607 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
608 bdb->bi_dbenv = NULL;
610 Debug( LDAP_DEBUG_ANY,
611 "bdb_db_close: close failed: %s (%d)\n",
612 db_strerror(rc), rc, 0 );
616 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2
617 /* Delete the environment if we were in quick mode. This
618 * works around a bug in bdb4.2 that interferes with the
619 * operation of db_stat and other tools after a slapadd -q
620 * or slapindex -q has taken place.
622 if( slapMode & SLAP_TOOL_QUICK ) {
623 rc = db_env_create( &bdb->bi_dbenv, 0 );
625 Debug( LDAP_DEBUG_ANY,
626 "bdb_db_close: db_env_create failed: %s (%d)\n",
627 db_strerror(rc), rc, 0 );
630 rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home,
632 bdb->bi_dbenv = NULL;
634 Debug( LDAP_DEBUG_ANY,
635 "bdb_db_close: dbenv_remove failed: %s (%d)\n",
636 db_strerror(rc), rc, 0 );
643 rc = alock_close( &bdb->bi_alock_info );
645 Debug( LDAP_DEBUG_ANY,
646 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
654 bdb_db_destroy( BackendDB *be )
656 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
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 bdb_attr_index_destroy( bdb->bi_attrs );
663 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
664 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
665 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
667 ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
669 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
670 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
671 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
672 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
675 be->be_private = NULL;
686 static char *controls[] = {
688 LDAP_CONTROL_MANAGEDSAIT,
690 LDAP_CONTROL_PAGEDRESULTS,
691 #ifdef LDAP_CONTROL_SUBENTRIES
692 LDAP_CONTROL_SUBENTRIES,
694 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
695 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
700 /* initialize the underlying database system */
701 Debug( LDAP_DEBUG_TRACE,
702 LDAP_XSTRING(bdb_back_initialize) ": initialize "
703 BDB_UCTYPE " backend\n", 0, 0, 0 );
706 SLAP_BFLAG_INCREMENT |
707 #ifdef BDB_SUBENTRIES
708 SLAP_BFLAG_SUBENTRIES |
711 SLAP_BFLAG_REFERRALS;
713 bi->bi_controls = controls;
715 { /* version check */
716 int major, minor, patch, ver;
717 char *version = db_version( &major, &minor, &patch );
721 /* All our stdio does an ASCII to EBCDIC conversion on
722 * the output. Strings from the BDB library are already
723 * in EBCDIC; we have to go back and forth...
725 strcpy( v2, version );
730 ver = (major << 24) | (minor << 16) | patch;
731 if( ver != DB_VERSION_FULL ) {
732 /* fail if a versions don't match */
733 Debug( LDAP_DEBUG_ANY,
734 LDAP_XSTRING(bdb_back_initialize) ": "
735 "BDB library version mismatch:"
736 " expected " DB_VERSION_STRING ","
737 " got %s\n", version, 0, 0 );
741 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
742 ": %s\n", version, 0, 0 );
745 db_env_set_func_free( ber_memfree );
746 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
747 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
749 /* This is a no-op on a NO_THREAD build. Leave the default
750 * alone so that BDB will sleep on interprocess conflicts.
752 db_env_set_func_yield( ldap_pvt_thread_yield );
760 bi->bi_db_init = bdb_db_init;
761 bi->bi_db_config = config_generic_wrapper;
762 bi->bi_db_open = bdb_db_open;
763 bi->bi_db_close = bdb_db_close;
764 bi->bi_db_destroy = bdb_db_destroy;
766 bi->bi_op_add = bdb_add;
767 bi->bi_op_bind = bdb_bind;
768 bi->bi_op_compare = bdb_compare;
769 bi->bi_op_delete = bdb_delete;
770 bi->bi_op_modify = bdb_modify;
771 bi->bi_op_modrdn = bdb_modrdn;
772 bi->bi_op_search = bdb_search;
774 bi->bi_op_unbind = 0;
776 bi->bi_extended = bdb_extended;
778 bi->bi_chk_referrals = bdb_referrals;
779 bi->bi_operational = bdb_operational;
780 bi->bi_has_subordinates = bdb_hasSubordinates;
781 bi->bi_entry_release_rw = bdb_entry_release;
782 bi->bi_entry_get_rw = bdb_entry_get;
785 * hooks for slap tools
787 bi->bi_tool_entry_open = bdb_tool_entry_open;
788 bi->bi_tool_entry_close = bdb_tool_entry_close;
789 bi->bi_tool_entry_first = bdb_tool_entry_next;
790 bi->bi_tool_entry_next = bdb_tool_entry_next;
791 bi->bi_tool_entry_get = bdb_tool_entry_get;
792 bi->bi_tool_entry_put = bdb_tool_entry_put;
793 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
794 bi->bi_tool_sync = 0;
795 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
796 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
797 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
799 bi->bi_connection_init = 0;
800 bi->bi_connection_destroy = 0;
802 rc = bdb_back_init_cf( bi );
807 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
808 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
810 /* conditionally define the init_module() function */
812 SLAP_BACKEND_INIT_MODULE( hdb )
813 #else /* !BDB_HIER */
814 SLAP_BACKEND_INIT_MODULE( bdb )
815 #endif /* !BDB_HIER */
817 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */