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 );
69 ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
70 ldap_pvt_thread_mutex_init( &bdb->bi_cache.c_dntree.bei_kids_mutex );
71 ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
74 be->be_cf_table = be->bd_info->bi_cf_table;
80 bdb_checkpoint( void *ctx, void *arg )
82 struct re_s *rtask = arg;
83 struct bdb_info *bdb = rtask->arg;
85 TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte,
86 bdb->bi_txn_cp_min, 0 );
87 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
88 ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
89 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
94 * Unconditionally perform a database recovery. Only works on
95 * databases that were previously opened with transactions and
99 bdb_do_recovery( BackendDB *be )
101 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
105 char path[MAXPATHLEN], *ptr;
107 /* Create and init the recovery environment */
108 rc = db_env_create( &re_dbenv, 0 );
110 Debug( LDAP_DEBUG_ANY,
111 "bdb_do_recovery: db_env_create failed: %s (%d)\n",
112 db_strerror(rc), rc, 0 );
115 re_dbenv->set_errpfx( re_dbenv, be->be_suffix[0].bv_val );
116 re_dbenv->set_errcall( re_dbenv, bdb_errcall );
117 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_RECOVERY, 1);
118 #if DB_VERSION_FULL < 0x04030000
119 (void)re_dbenv->set_verbose(re_dbenv, DB_VERB_CHKPOINT, 1);
121 re_dbenv->set_msgcall( re_dbenv, bdb_msgcall );
124 flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
125 DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER;
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 );
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 ldap_pvt_thread_rdwr_init( &bdb->bi_idl_tree_rwlock );
397 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_lrulock );
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 /* If we're in server mode and time-based checkpointing is enabled,
539 * submit a task to perform periodic checkpoints.
541 if (( slapMode & SLAP_SERVER_MODE ) && bdb->bi_txn_cp &&
542 bdb->bi_txn_cp_min ) {
543 ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
544 ldap_pvt_runqueue_insert( &slapd_rq, bdb->bi_txn_cp_min*60,
545 bdb_checkpoint, bdb );
546 ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
549 if (( slapMode&SLAP_SERVER_MODE ) && ( bdb->bi_flags&BDB_HAS_CONFIG )) {
550 char buf[SLAP_TEXT_BUFLEN];
551 FILE *f = fopen( bdb->bi_db_config_path, "r" );
555 while ( fgets( buf, sizeof(buf), f )) {
556 ber_str2bv( buf, 0, 1, &bv );
557 if ( bv.bv_val[bv.bv_len-1] == '\n' ) {
559 bv.bv_val[bv.bv_len] = '\0';
561 /* shouldn't need this, but ... */
562 if ( bv.bv_val[bv.bv_len-1] == '\r' ) {
564 bv.bv_val[bv.bv_len] = '\0';
566 ber_bvarray_add( &bdb->bi_db_config, &bv );
570 /* Eh? It disappeared between config and open?? */
571 bdb->bi_flags &= ~BDB_HAS_CONFIG;
575 bdb->bi_flags |= BDB_IS_OPEN;
581 bdb_db_close( BackendDB *be )
584 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
585 struct bdb_db_info *db;
586 bdb_idl_cache_entry_t *entry, *next_entry;
588 bdb->bi_flags &= ~BDB_IS_OPEN;
590 ber_bvarray_free( bdb->bi_db_config );
592 while( bdb->bi_ndatabases-- ) {
593 db = bdb->bi_databases[bdb->bi_ndatabases];
594 rc = db->bdi_db->close( db->bdi_db, 0 );
595 /* Lower numbered names are not strdup'd */
596 if( bdb->bi_ndatabases >= BDB_NDB )
597 free( db->bdi_name );
600 free( bdb->bi_databases );
601 bdb_attr_index_destroy( bdb->bi_attrs );
603 bdb_cache_release_all (&bdb->bi_cache);
605 if ( bdb->bi_idl_cache_max_size ) {
606 ldap_pvt_thread_rdwr_wlock ( &bdb->bi_idl_tree_rwlock );
607 avl_free( bdb->bi_idl_tree, NULL );
608 entry = bdb->bi_idl_lru_head;
609 while ( entry != NULL ) {
610 next_entry = entry->idl_lru_next;
613 free( entry->kstr.bv_val );
617 ldap_pvt_thread_rdwr_wunlock ( &bdb->bi_idl_tree_rwlock );
620 if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_dbenv ) {
621 XLOCK_ID_FREE(bdb->bi_dbenv, bdb->bi_cache.c_locker);
628 bdb_db_destroy( BackendDB *be )
631 struct bdb_info *bdb = (struct bdb_info *) be->be_private;
633 /* close db environment */
634 if( bdb->bi_dbenv ) {
635 /* force a checkpoint */
636 if ( !( slapMode & SLAP_TOOL_QUICK )) {
637 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
639 Debug( LDAP_DEBUG_ANY,
640 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
641 db_strerror(rc), rc, 0 );
645 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
646 bdb->bi_dbenv = NULL;
648 Debug( LDAP_DEBUG_ANY,
649 "bdb_db_destroy: close failed: %s (%d)\n",
650 db_strerror(rc), rc, 0 );
655 rc = alock_close( &bdb->bi_alock_info );
657 Debug( LDAP_DEBUG_ANY,
658 "bdb_db_destroy: alock_close failed\n", 0, 0, 0 );
662 if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
663 if( bdb->bi_db_config_path ) ch_free( bdb->bi_db_config_path );
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 );
668 ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
669 ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
670 if ( bdb->bi_idl_cache_max_size ) {
671 ldap_pvt_thread_rdwr_destroy( &bdb->bi_idl_tree_rwlock );
672 ldap_pvt_thread_mutex_destroy( &bdb->bi_idl_tree_lrulock );
676 be->be_private = NULL;
687 static char *controls[] = {
689 LDAP_CONTROL_MANAGEDSAIT,
691 LDAP_CONTROL_PAGEDRESULTS,
692 #ifdef LDAP_CONTROL_SUBENTRIES
693 LDAP_CONTROL_SUBENTRIES,
695 #ifdef LDAP_CONTROL_X_PERMISSIVE_MODIFY
696 LDAP_CONTROL_X_PERMISSIVE_MODIFY,
701 /* initialize the underlying database system */
702 Debug( LDAP_DEBUG_TRACE,
703 LDAP_XSTRING(bdb_back_initialize) ": initialize "
704 BDB_UCTYPE " backend\n", 0, 0, 0 );
707 SLAP_BFLAG_INCREMENT |
708 #ifdef BDB_SUBENTRIES
709 SLAP_BFLAG_SUBENTRIES |
712 SLAP_BFLAG_REFERRALS;
714 bi->bi_controls = controls;
716 { /* version check */
717 int major, minor, patch, ver;
718 char *version = db_version( &major, &minor, &patch );
722 /* All our stdio does an ASCII to EBCDIC conversion on
723 * the output. Strings from the BDB library are already
724 * in EBCDIC; we have to go back and forth...
726 strcpy( v2, version );
731 ver = (major << 24) | (minor << 16) | patch;
732 if( ver != DB_VERSION_FULL ) {
733 /* fail if a versions don't match */
734 Debug( LDAP_DEBUG_ANY,
735 LDAP_XSTRING(bdb_back_initialize) ": "
736 "BDB library version mismatch:"
737 " expected " DB_VERSION_STRING ","
738 " got %s\n", version, 0, 0 );
742 Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_back_initialize)
743 ": %s\n", version, 0, 0 );
746 db_env_set_func_free( ber_memfree );
747 db_env_set_func_malloc( (db_malloc *)ber_memalloc );
748 db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
750 /* This is a no-op on a NO_THREAD build. Leave the default
751 * alone so that BDB will sleep on interprocess conflicts.
753 db_env_set_func_yield( ldap_pvt_thread_yield );
761 bi->bi_db_init = bdb_db_init;
762 bi->bi_db_config = config_generic_wrapper;
763 bi->bi_db_open = bdb_db_open;
764 bi->bi_db_close = bdb_db_close;
765 bi->bi_db_destroy = bdb_db_destroy;
767 bi->bi_op_add = bdb_add;
768 bi->bi_op_bind = bdb_bind;
769 bi->bi_op_compare = bdb_compare;
770 bi->bi_op_delete = bdb_delete;
771 bi->bi_op_modify = bdb_modify;
772 bi->bi_op_modrdn = bdb_modrdn;
773 bi->bi_op_search = bdb_search;
775 bi->bi_op_unbind = 0;
777 bi->bi_extended = bdb_extended;
779 bi->bi_chk_referrals = bdb_referrals;
780 bi->bi_operational = bdb_operational;
781 bi->bi_has_subordinates = bdb_hasSubordinates;
782 bi->bi_entry_release_rw = bdb_entry_release;
783 bi->bi_entry_get_rw = bdb_entry_get;
786 * hooks for slap tools
788 bi->bi_tool_entry_open = bdb_tool_entry_open;
789 bi->bi_tool_entry_close = bdb_tool_entry_close;
790 bi->bi_tool_entry_first = bdb_tool_entry_next;
791 bi->bi_tool_entry_next = bdb_tool_entry_next;
792 bi->bi_tool_entry_get = bdb_tool_entry_get;
793 bi->bi_tool_entry_put = bdb_tool_entry_put;
794 bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
795 bi->bi_tool_sync = 0;
796 bi->bi_tool_dn2id_get = bdb_tool_dn2id_get;
797 bi->bi_tool_id2entry_get = bdb_tool_id2entry_get;
798 bi->bi_tool_entry_modify = bdb_tool_entry_modify;
800 bi->bi_connection_init = 0;
801 bi->bi_connection_destroy = 0;
803 rc = bdb_back_init_cf( bi );
808 #if (SLAPD_BDB == SLAPD_MOD_DYNAMIC && !defined(BDB_HIER)) || \
809 (SLAPD_HDB == SLAPD_MOD_DYNAMIC && defined(BDB_HIER))
811 /* conditionally define the init_module() function */
813 SLAP_BACKEND_INIT_MODULE( hdb )
814 #else /* !BDB_HIER */
815 SLAP_BACKEND_INIT_MODULE( bdb )
816 #endif /* !BDB_HIER */
818 #endif /* SLAPD_[BH]DB == SLAPD_MOD_DYNAMIC */