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 );
249 Debug( LDAP_DEBUG_ANY,
250 "bdb_db_recover: Database cannot be recovered. "\
251 "Restore from backup!\n", 0, 0, 0);
258 bdb_db_open( BackendDB *be )
261 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
262 struct stat stat1, stat2;
264 char path[MAXPATHLEN];
267 Debug( LDAP_DEBUG_ARGS,
269 be->be_suffix[0].bv_val, 0, 0 );
271 #ifndef BDB_MULTIPLE_SUFFIXES
272 if ( be->be_suffix[1].bv_val ) {
273 Debug( LDAP_DEBUG_ANY,
274 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
279 /* Check existence of dbenv_home. Any error means trouble */
280 rc = stat( bdb->bi_dbenv_home, &stat1 );
282 Debug( LDAP_DEBUG_ANY,
283 "bdb_db_open: Cannot access database directory %s (%d)\n",
284 bdb->bi_dbenv_home, errno, 0 );
288 /* Perform database use arbitration/recovery logic */
289 rc = alock_open( &bdb->bi_alock_info,
292 slapMode & SLAP_TOOL_READONLY ?
293 ALOCK_LOCKED : ALOCK_UNIQUE );
295 if( rc == ALOCK_RECOVER ) {
296 Debug( LDAP_DEBUG_ANY,
297 "bdb_db_open: unclean shutdown detected;"
298 " attempting recovery.\n",
300 if( bdb_db_recover( be ) != 0 ) {
301 Debug( LDAP_DEBUG_ANY,
302 "bdb_db_open: DB recovery failed.\n",
306 if( alock_recover (&bdb->bi_alock_info) != 0 ) {
307 Debug( LDAP_DEBUG_ANY,
308 "bdb_db_open: alock_recover failed\n",
313 } else if( rc == ALOCK_BUSY ) {
314 Debug( LDAP_DEBUG_ANY,
315 "bdb_db_open: database already in use\n",
318 } else if( rc != ALOCK_CLEAN ) {
319 Debug( LDAP_DEBUG_ANY,
320 "bdb_db_open: alock package is unstable\n",
326 * The DB_CONFIG file may have changed. If so, recover the
327 * database so that new settings are put into effect. Also
328 * note the possible absence of DB_CONFIG in the log.
330 if( stat( bdb->bi_db_config_path, &stat1 ) == 0 ) {
331 ptr = lutil_strcopy(path, bdb->bi_dbenv_home);
332 *ptr++ = LDAP_DIRSEP[0];
333 strcpy( ptr, bdbi_databases[0].file);
334 if( stat( path, &stat2 ) == 0 ) {
335 if( stat2.st_mtime <= stat1.st_mtime ) {
336 Debug( LDAP_DEBUG_ANY,
337 "bdb_db_open: DB_CONFIG for suffix %s has changed.\n"
338 "Performing database recovery to activate new settings.\n",
339 be->be_suffix[0].bv_val, 0, 0 );
340 if( bdb_do_recovery( be ) != 0) {
341 Debug( LDAP_DEBUG_ANY,
342 "bdb_db_open: db recovery failed.\n",
351 Debug( LDAP_DEBUG_ANY,
352 "bdb_db_open: Warning - No DB_CONFIG file found "
353 "in directory %s: (%d)\n"
354 "Expect poor performance for suffix %s.\n",
355 bdb->bi_dbenv_home, errno, be->be_suffix[0].bv_val );
358 flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE;
359 if ( !( slapMode & SLAP_TOOL_QUICK ))
360 flags |= DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
362 rc = db_env_create( &bdb->bi_dbenv, 0 );
364 Debug( LDAP_DEBUG_ANY,
365 "bdb_db_open: db_env_create failed: %s (%d)\n",
366 db_strerror(rc), rc, 0 );
370 /* If a key was set, use shared memory for the BDB environment */
371 if ( bdb->bi_shm_key ) {
372 bdb->bi_dbenv->set_shm_key( bdb->bi_dbenv, bdb->bi_shm_key );
373 flags |= DB_SYSTEM_MEM;
376 bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
377 bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
378 bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
380 /* One long-lived TXN per thread, two TXNs per write op */
381 bdb->bi_dbenv->set_tx_max( bdb->bi_dbenv, connection_pool_max * 3 );
383 #ifdef SLAP_ZONE_ALLOC
384 if ( bdb->bi_cache.c_maxsize ) {
385 bdb->bi_cache.c_zctx = slap_zn_mem_create(
393 if ( bdb->bi_idl_cache_max_size ) {
394 bdb->bi_idl_tree = NULL;
395 bdb->bi_idl_cache_size = 0;
398 if( bdb->bi_dbenv_xflags != 0 ) {
399 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
400 bdb->bi_dbenv_xflags, 1);
402 Debug( LDAP_DEBUG_ANY,
403 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
404 db_strerror(rc), rc, 0 );
409 Debug( LDAP_DEBUG_TRACE,
410 "bdb_db_open: dbenv_open(%s)\n",
411 bdb->bi_dbenv_home, 0, 0);
414 strcpy( path, bdb->bi_dbenv_home );
416 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
419 bdb->bi_dbenv_mode );
421 rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
424 bdb->bi_dbenv_mode );
427 Debug( LDAP_DEBUG_ANY,
428 "bdb_db_open: dbenv_open failed: %s (%d)\n",
429 db_strerror(rc), rc, 0 );
433 flags = DB_THREAD | bdb->bi_db_opflags;
435 #ifdef DB_AUTO_COMMIT
436 if ( !( slapMode & SLAP_TOOL_QUICK ))
437 flags |= DB_AUTO_COMMIT;
440 bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
441 BDB_INDICES * sizeof(struct bdb_db_info *) );
443 /* open (and create) main database */
444 for( i = 0; bdbi_databases[i].name; i++ ) {
445 struct bdb_db_info *db;
447 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
449 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
451 Debug( LDAP_DEBUG_ANY,
452 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
453 bdb->bi_dbenv_home, db_strerror(rc), rc );
457 if( i == BDB_ID2ENTRY ) {
458 rc = db->bdi_db->set_pagesize( db->bdi_db,
459 BDB_ID2ENTRY_PAGESIZE );
460 if ( slapMode & SLAP_TOOL_READMAIN ) {
466 rc = db->bdi_db->set_flags( db->bdi_db,
467 DB_DUP | DB_DUPSORT );
469 if ( slapMode & SLAP_TOOL_READONLY ) {
475 if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
481 rc = db->bdi_db->set_pagesize( db->bdi_db,
486 strcpy( path, bdbi_databases[i].file );
488 rc = DB_OPEN( db->bdi_db,
490 /* bdbi_databases[i].name, */ NULL,
491 bdbi_databases[i].type,
492 bdbi_databases[i].flags | flags,
493 bdb->bi_dbenv_mode );
495 rc = DB_OPEN( db->bdi_db,
496 bdbi_databases[i].file,
497 /* bdbi_databases[i].name, */ NULL,
498 bdbi_databases[i].type,
499 bdbi_databases[i].flags | flags,
500 bdb->bi_dbenv_mode );
504 char buf[SLAP_TEXT_BUFLEN];
506 snprintf( buf, sizeof(buf), "%s/%s",
507 bdb->bi_dbenv_home, bdbi_databases[i].file );
508 Debug( LDAP_DEBUG_ANY,
509 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
510 buf, db_strerror(rc), rc );
514 flags &= ~(DB_CREATE | DB_RDONLY);
515 db->bdi_name = bdbi_databases[i].name;
516 bdb->bi_databases[i] = db;
519 bdb->bi_databases[i] = NULL;
520 bdb->bi_ndatabases = i;
523 rc = bdb_last_id( be, NULL );
525 Debug( LDAP_DEBUG_ANY,
526 "bdb_db_open: last_id(%s) failed: %s (%d)\n",
527 bdb->bi_dbenv_home, db_strerror(rc), rc );
531 if ( !( slapMode & SLAP_TOOL_QUICK )) {
532 XLOCK_ID(bdb->bi_dbenv, &bdb->bi_cache.c_locker);
535 bdb->bi_flags |= BDB_IS_OPEN;
541 bdb_db_close( BackendDB *be )
544 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
545 struct bdb_db_info *db;
546 bdb_idl_cache_entry_t *entry, *next_entry;
548 /* backend_shutdown closes everything, even if not all were opened */
549 if ( !( bdb->bi_flags & BDB_IS_OPEN ))
552 bdb->bi_flags &= ~BDB_IS_OPEN;
554 ber_bvarray_free( bdb->bi_db_config );
555 bdb->bi_db_config = NULL;
557 while( bdb->bi_databases && bdb->bi_ndatabases-- ) {
558 db = bdb->bi_databases[bdb->bi_ndatabases];
559 rc = db->bdi_db->close( db->bdi_db, 0 );
560 /* Lower numbered names are not strdup'd */
561 if( bdb->bi_ndatabases >= BDB_NDB )
562 free( db->bdi_name );
565 free( bdb->bi_databases );
566 bdb->bi_databases = NULL;
568 bdb_cache_release_all (&bdb->bi_cache);
570 if ( bdb->bi_idl_cache_max_size ) {
571 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
572 avl_free( bdb->bi_idl_tree, NULL );
573 bdb->bi_idl_tree = NULL;
574 entry = bdb->bi_idl_lru_head;
575 while ( entry != NULL ) {
576 next_entry = entry->idl_lru_next;
579 free( entry->kstr.bv_val );
583 bdb->bi_idl_lru_head = bdb->bi_idl_lru_tail = NULL;
584 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
587 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
588 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
589 bdb->bi_cache.c_locker = 0;
592 /* close db environment */
593 if( bdb->bi_dbenv ) {
594 /* force a checkpoint, but not if we were ReadOnly,
595 * and not in Quick mode since there are no transactions there.
597 if ( !( slapMode & ( SLAP_TOOL_QUICK|SLAP_TOOL_READONLY ))) {
598 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
600 Debug( LDAP_DEBUG_ANY,
601 "bdb_db_close: txn_checkpoint failed: %s (%d)\n",
602 db_strerror(rc), rc, 0 );
606 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
607 bdb->bi_dbenv = NULL;
609 Debug( LDAP_DEBUG_ANY,
610 "bdb_db_close: close failed: %s (%d)\n",
611 db_strerror(rc), rc, 0 );
615 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 2
616 /* Delete the environment if we were in quick mode. This
617 * works around a bug in bdb4.2 that interferes with the
618 * operation of db_stat and other tools after a slapadd -q
619 * or slapindex -q has taken place.
621 if( slapMode & SLAP_TOOL_QUICK ) {
622 rc = db_env_create( &bdb->bi_dbenv, 0 );
624 Debug( LDAP_DEBUG_ANY,
625 "bdb_db_close: db_env_create failed: %s (%d)\n",
626 db_strerror(rc), rc, 0 );
629 rc = bdb->bi_dbenv->remove(bdb->bi_dbenv, bdb->bi_dbenv_home,
631 bdb->bi_dbenv = NULL;
633 Debug( LDAP_DEBUG_ANY,
634 "bdb_db_close: dbenv_remove failed: %s (%d)\n",
635 db_strerror(rc), rc, 0 );
642 rc = alock_close( &bdb->bi_alock_info );
644 Debug( LDAP_DEBUG_ANY,
645 "bdb_db_close: alock_close failed\n", 0, 0, 0 );
653 bdb_db_destroy( BackendDB *be )
655 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
657 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
658 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
660 bdb_attr_index_destroy( bdb->bi_attrs );
662 ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
663 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
664 ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.c_dntree.bei_kids_mutex );
666 ldap_pvt_thread_mutex_destroy( &bdb->bi_modrdns_mutex );
668 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
669 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
670 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
671 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
674 be->be_private = NULL;
685 static char *controls[] = {
687 LDAP_CONTROL_MANAGEDSAIT,
689 LDAP_CONTROL_PAGEDRESULTS,
690 #ifdef LDAP_CONTROL_SUBENTRIES
691 LDAP_CONTROL_SUBENTRIES,
693 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
694 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
699 /* initialize the underlying database system */
700 Debug( LDAP_DEBUG_TRACE,
701 LDAP_XSTRING(bdb_back_initialize) ": initialize "
702 BDB_UCTYPE " backend\n", 0, 0, 0 );
705 SLAP_BFLAG_INCREMENT |
706 #ifdef BDB_SUBENTRIES
707 SLAP_BFLAG_SUBENTRIES |
710 SLAP_BFLAG_REFERRALS;
712 bi->bi_controls = controls;
714 { /* version check */
715 int major, minor, patch, ver;
716 char *version = db_version( &major, &minor, &patch );
720 /* All our stdio does an ASCII to EBCDIC conversion on
721 * the output. Strings from the BDB library are already
722 * in EBCDIC; we have to go back and forth...
724 strcpy( v2, version );
729 ver = (major << 24) | (minor << 16) | patch;
730 if( ver != DB_VERSION_FULL ) {
731 /* fail if a versions don't match */
732 Debug( LDAP_DEBUG_ANY,
733 LDAP_XSTRING(bdb_back_initialize) ": "
734 "BDB library version mismatch:"
735 " expected " DB_VERSION_STRING ","
736 " got %s\n", version, 0, 0 );
740 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
741 ": %s\n", version, 0, 0 );
744 db_env_set_func_free( ber_memfree );
745 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
746 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
748 /* This is a no-op on a NO_THREAD build. Leave the default
749 * alone so that BDB will sleep on interprocess conflicts.
751 db_env_set_func_yield( ldap_pvt_thread_yield );
759 bi->bi_db_init = bdb_db_init;
760 bi->bi_db_config = config_generic_wrapper;
761 bi->bi_db_open = bdb_db_open;
762 bi->bi_db_close = bdb_db_close;
763 bi->bi_db_destroy = bdb_db_destroy;
765 bi->bi_op_add = bdb_add;
766 bi->bi_op_bind = bdb_bind;
767 bi->bi_op_compare = bdb_compare;
768 bi->bi_op_delete = bdb_delete;
769 bi->bi_op_modify = bdb_modify;
770 bi->bi_op_modrdn = bdb_modrdn;
771 bi->bi_op_search = bdb_search;
773 bi->bi_op_unbind = 0;
775 bi->bi_extended = bdb_extended;
777 bi->bi_chk_referrals = bdb_referrals;
778 bi->bi_operational = bdb_operational;
779 bi->bi_has_subordinates = bdb_hasSubordinates;
780 bi->bi_entry_release_rw = bdb_entry_release;
781 bi->bi_entry_get_rw = bdb_entry_get;
784 * hooks for slap tools
786 bi->bi_tool_entry_open = bdb_tool_entry_open;
787 bi->bi_tool_entry_close = bdb_tool_entry_close;
788 bi->bi_tool_entry_first = bdb_tool_entry_next;
789 bi->bi_tool_entry_next = bdb_tool_entry_next;
790 bi->bi_tool_entry_get = bdb_tool_entry_get;
791 bi->bi_tool_entry_put = bdb_tool_entry_put;
792 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
793 bi->bi_tool_sync = 0;
794 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
795 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
796 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
798 bi->bi_connection_init = 0;
799 bi->bi_connection_destroy = 0;
801 rc = bdb_back_init_cf( bi );
806 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
807 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
809 /* conditionally define the init_module() function */
811 SLAP_BACKEND_INIT_MODULE( hdb )
812 #else /* !BDB_HIER */
813 SLAP_BACKEND_INIT_MODULE( bdb )
814 #endif /* !BDB_HIER */
816 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */