]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/init.c
Use function pointers to get at backend routines.
[openldap] / servers / slapd / back-bdb / init.c
1 /* init.c - initialize bdb backend */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11 #include <ac/string.h>
12 #include <ac/unistd.h>
13 #include <ac/stdlib.h>
14
15 #include <lutil.h>
16
17 #include "back-bdb.h"
18 #include "external.h"
19
20 static struct bdbi_database {
21         char *file;
22         char *name;
23         int type;
24         int flags;
25 } bdbi_databases[] = {
26         { "id2entry" BDB_SUFFIX, "id2entry", DB_BTREE, 0 },
27 #ifdef BDB_HIER
28         { "id2parent" BDB_SUFFIX, "id2parent", DB_BTREE, 0 },
29 #else
30         { "dn2id" BDB_SUFFIX, "dn2id", DB_BTREE, 0 },
31 #endif
32         { NULL, NULL, 0, 0 }
33 };
34
35 struct berval bdb_uuid = { 0, NULL };
36
37 typedef void * db_malloc(size_t);
38 typedef void * db_realloc(void *, size_t);
39
40 #if 0
41 static int
42 bdb_open( BackendInfo *bi )
43 {
44         return 0;
45 }
46
47 static int
48 bdb_destroy( BackendInfo *bi )
49 {
50         return 0;
51 }
52
53 static int
54 bdb_close( BackendInfo *bi )
55 {
56         /* terminate the underlying database system */
57         return 0;
58 }
59 #endif
60
61 static int
62 bdb_db_init( BackendDB *be )
63 {
64         struct bdb_info *bdb;
65
66 #ifdef NEW_LOGGING
67         LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_init", 0, 0, 0 );
68 #else
69         Debug( LDAP_DEBUG_ANY,
70                 "bdb_db_init: Initializing BDB database\n",
71                 0, 0, 0 );
72 #endif
73
74         /* indicate system schema supported */
75         be->be_flags |=
76 #ifdef BDB_SUBENTRIES
77                 SLAP_BFLAG_SUBENTRIES |
78 #endif
79 #ifdef BDB_ALIASES
80                 SLAP_BFLAG_ALIASES |
81 #endif
82                 SLAP_BFLAG_REFERRALS;
83
84         /* allocate backend-database-specific stuff */
85         bdb = (struct bdb_info *) ch_calloc( 1, sizeof(struct bdb_info) );
86
87         /* DBEnv parameters */
88         bdb->bi_dbenv_home = ch_strdup( SLAPD_DEFAULT_DB_DIR );
89         bdb->bi_dbenv_xflags = 0;
90         bdb->bi_dbenv_mode = SLAPD_DEFAULT_DB_MODE;
91
92         bdb->bi_cache.c_maxsize = DEFAULT_CACHE_SIZE;
93
94         bdb->bi_lock_detect = DB_LOCK_DEFAULT;
95         bdb->bi_search_stack_depth = DEFAULT_SEARCH_STACK_DEPTH;
96         bdb->bi_search_stack = NULL;
97
98 #if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
99         LDAP_LIST_INIT (&bdb->psearch_list);
100 #endif
101
102         ldap_pvt_thread_mutex_init( &bdb->bi_database_mutex );
103         ldap_pvt_thread_mutex_init( &bdb->bi_lastid_mutex );
104         ldap_pvt_thread_mutex_init( &bdb->bi_cache.lru_mutex );
105         ldap_pvt_thread_rdwr_init ( &bdb->bi_cache.c_rwlock );
106 #ifdef BDB_HIER
107         ldap_pvt_thread_rdwr_init( &bdb->bi_tree_rdwr );
108 #endif
109
110         be->be_private = bdb;
111
112         return 0;
113 }
114
115 int
116 bdb_bt_compare(
117         DB *db, 
118         const DBT *usrkey,
119         const DBT *curkey
120 )
121 {
122         unsigned char *u, *c;
123         int i, x;
124
125         u = usrkey->data;
126         c = curkey->data;
127
128 #ifdef WORDS_BIGENDIAN
129         for( i = 0; i < (int)sizeof(ID); i++)
130 #else
131         for( i = sizeof(ID)-1; i >= 0; i--)
132 #endif
133         {
134                 x = u[i] - c[i];
135                 if( x ) return x;
136         }
137
138         return 0;
139 }
140
141 static int
142 bdb_db_open( BackendDB *be )
143 {
144         int rc, i;
145         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
146         u_int32_t flags;
147 #ifdef HAVE_EBCDIC
148         char path[MAXPATHLEN];
149 #endif
150
151 #ifdef NEW_LOGGING
152         LDAP_LOG( BACK_BDB, ARGS, 
153                 "bdb_db_open: %s\n", be->be_suffix[0].bv_val, 0, 0 );
154 #else
155         Debug( LDAP_DEBUG_ARGS,
156                 "bdb_db_open: %s\n",
157                 be->be_suffix[0].bv_val, 0, 0 );
158 #endif
159
160 #ifndef BDB_MULTIPLE_SUFFIXES
161         if ( be->be_suffix[1].bv_val ) {
162 #ifdef NEW_LOGGING
163         LDAP_LOG( BACK_BDB, ARGS, 
164                 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
165 #else
166         Debug( LDAP_DEBUG_ARGS,
167                 "bdb_db_open: only one suffix allowed\n", 0, 0, 0 );
168 #endif
169                 return -1;
170         }
171 #endif
172         /* we should check existance of dbenv_home and db_directory */
173
174         rc = db_env_create( &bdb->bi_dbenv, 0 );
175         if( rc != 0 ) {
176 #ifdef NEW_LOGGING
177                 LDAP_LOG( BACK_BDB, ERR, 
178                         "bdb_db_open: db_env_create failed: %s (%d)\n", 
179                         db_strerror(rc), rc, 0 );
180 #else
181                 Debug( LDAP_DEBUG_ANY,
182                         "bdb_db_open: db_env_create failed: %s (%d)\n",
183                         db_strerror(rc), rc, 0 );
184 #endif
185                 return rc;
186         }
187
188         flags = DB_INIT_MPOOL | DB_THREAD | DB_CREATE
189                 | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN;
190         
191 #if 0
192         /* Never do automatic recovery, must perform it manually.
193          * Otherwise restarting with gentlehup will corrupt the
194          * database.
195          */
196         if( !(slapMode & SLAP_TOOL_MODE) ) flags |= DB_RECOVER;
197 #endif
198
199         bdb->bi_dbenv->set_errpfx( bdb->bi_dbenv, be->be_suffix[0].bv_val );
200         bdb->bi_dbenv->set_errcall( bdb->bi_dbenv, bdb_errcall );
201         bdb->bi_dbenv->set_lk_detect( bdb->bi_dbenv, bdb->bi_lock_detect );
202
203 #ifdef SLAP_IDL_CACHE
204         if ( bdb->bi_idl_cache_max_size ) {
205                 ldap_pvt_thread_mutex_init( &bdb->bi_idl_tree_mutex );
206                 bdb->bi_idl_cache_size = 0;
207         }
208 #endif
209
210 #ifdef BDB_SUBDIRS
211         {
212                 char dir[MAXPATHLEN];
213                 size_t len = strlen( bdb->bi_dbenv_home );
214
215                 strcpy( dir, bdb->bi_dbenv_home );
216                 strcat( &dir[len], BDB_TMP_SUBDIR );
217                 
218                 rc = bdb->bi_dbenv->set_tmp_dir( bdb->bi_dbenv, dir );
219                 if( rc != 0 ) {
220 #ifdef NEW_LOGGING
221                         LDAP_LOG( BACK_BDB, ERR, 
222                                 "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n", 
223                                 dir, db_strerror(rc), rc );
224 #else
225                         Debug( LDAP_DEBUG_ANY,
226                                 "bdb_db_open: set_tmp_dir(%s) failed: %s (%d)\n",
227                                 dir, db_strerror(rc), rc );
228 #endif
229                         return rc;
230                 }
231
232                 strcat( &dir[len], BDB_LG_SUBDIR );
233
234                 rc = bdb->bi_dbenv->set_lg_dir( bdb->bi_dbenv, dir );
235                 if( rc != 0 ) {
236 #ifdef NEW_LOGGING
237                         LDAP_LOG( BACK_BDB, ERR, 
238                                 "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n", 
239                                 dir, db_strerror(rc), rc );
240 #else
241                         Debug( LDAP_DEBUG_ANY,
242                                 "bdb_db_open: set_lg_dir(%s) failed: %s (%d)\n",
243                                 dir, db_strerror(rc), rc );
244 #endif
245                         return rc;
246                 }
247
248                 strcat( &dir[len], BDB_DATA_SUBDIR );
249
250                 rc = bdb->bi_dbenv->set_data_dir( bdb->bi_dbenv, dir );
251                 if( rc != 0 ) {
252 #ifdef NEW_LOGGING
253                         LDAP_LOG( BACK_BDB, ERR, 
254                                 "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n",
255                                 dir, db_strerror(rc), rc );
256 #else
257                         Debug( LDAP_DEBUG_ANY,
258                                 "bdb_db_open: set_data_dir(%s) failed: %s (%d)\n",
259                                 dir, db_strerror(rc), rc );
260 #endif
261                         return rc;
262                 }
263         }
264 #endif
265
266 #ifdef NEW_LOGGING
267         LDAP_LOG( BACK_BDB, DETAIL1, 
268                 "bdb_db_open: dbenv_open %s\n", bdb->bi_dbenv_home, 0, 0 );
269 #else
270         Debug( LDAP_DEBUG_TRACE,
271                 "bdb_db_open: dbenv_open(%s)\n",
272                 bdb->bi_dbenv_home, 0, 0);
273 #endif
274
275 #ifdef HAVE_EBCDIC
276         strcpy( path, bdb->bi_dbenv_home );
277         __atoe( path );
278         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
279                 path,
280                 flags,
281                 bdb->bi_dbenv_mode );
282 #else
283         rc = bdb->bi_dbenv->open( bdb->bi_dbenv,
284                 bdb->bi_dbenv_home,
285                 flags,
286                 bdb->bi_dbenv_mode );
287 #endif
288         if( rc != 0 ) {
289 #ifdef NEW_LOGGING
290                 LDAP_LOG( BACK_BDB, ERR, 
291                         "bdb_db_open: dbenv_open failed: %s (%d)\n", 
292                         db_strerror(rc), rc, 0 );
293 #else
294                 Debug( LDAP_DEBUG_ANY,
295                         "bdb_db_open: dbenv_open failed: %s (%d)\n",
296                         db_strerror(rc), rc, 0 );
297 #endif
298                 return rc;
299         }
300
301         if( bdb->bi_dbenv_xflags != 0 ) {
302                 rc = bdb->bi_dbenv->set_flags( bdb->bi_dbenv,
303                         bdb->bi_dbenv_xflags, 1);
304                 if( rc != 0 ) {
305 #ifdef NEW_LOGGING
306                         LDAP_LOG( BACK_BDB, ERR, 
307                                 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n", 
308                                 db_strerror(rc), rc, 0 );
309 #else
310                         Debug( LDAP_DEBUG_ANY,
311                                 "bdb_db_open: dbenv_set_flags failed: %s (%d)\n",
312                                 db_strerror(rc), rc, 0 );
313 #endif
314                         return rc;
315                 }
316         }
317
318         flags = DB_THREAD | DB_CREATE | bdb->bi_db_opflags;
319
320         bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
321                 BDB_INDICES * sizeof(struct bdb_db_info *) );
322
323         /* open (and create) main database */
324         for( i = 0; bdbi_databases[i].name; i++ ) {
325                 struct bdb_db_info *db;
326
327                 db = (struct bdb_db_info *) ch_calloc(1, sizeof(struct bdb_db_info));
328
329                 rc = db_create( &db->bdi_db, bdb->bi_dbenv, 0 );
330                 if( rc != 0 ) {
331 #ifdef NEW_LOGGING
332                         LDAP_LOG( BACK_BDB, ERR, 
333                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n", 
334                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
335 #else
336                         Debug( LDAP_DEBUG_ANY,
337                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n",
338                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
339 #endif
340                         return rc;
341                 }
342
343                 if( i == BDB_ID2ENTRY ) {
344                         rc = db->bdi_db->set_bt_compare( db->bdi_db,
345                                 bdb_bt_compare );
346                         rc = db->bdi_db->set_pagesize( db->bdi_db,
347                                 BDB_ID2ENTRY_PAGESIZE );
348                 } else {
349 #ifdef BDB_HIER
350                         rc = db->bdi_db->set_bt_compare( db->bdi_db,
351                                 bdb_bt_compare );
352 #else
353                         rc = db->bdi_db->set_flags( db->bdi_db, 
354                                 DB_DUP | DB_DUPSORT );
355                         rc = db->bdi_db->set_dup_compare( db->bdi_db,
356                                 bdb_bt_compare );
357 #endif
358                         rc = db->bdi_db->set_pagesize( db->bdi_db,
359                                 BDB_PAGESIZE );
360                 }
361
362 #ifdef HAVE_EBCDIC
363                 strcpy( path, bdbi_databases[i].file );
364                 __atoe( path );
365                 rc = DB_OPEN( db->bdi_db, 
366                         path,
367                 /*      bdbi_databases[i].name, */ NULL,
368                         bdbi_databases[i].type,
369                         bdbi_databases[i].flags | flags,
370                         bdb->bi_dbenv_mode );
371 #else
372                 rc = DB_OPEN( db->bdi_db, 
373                         bdbi_databases[i].file,
374                 /*      bdbi_databases[i].name, */ NULL,
375                         bdbi_databases[i].type,
376                         bdbi_databases[i].flags | flags,
377                         bdb->bi_dbenv_mode );
378 #endif
379
380                 if( rc != 0 ) {
381 #ifdef NEW_LOGGING
382                         LDAP_LOG( BACK_BDB, ERR, 
383                                 "bdb_db_open: db_create(%s) failed: %s (%d)\n", 
384                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
385 #else
386                         Debug( LDAP_DEBUG_ANY,
387                                 "bdb_db_open: db_open(%s) failed: %s (%d)\n",
388                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
389 #endif
390                         return rc;
391                 }
392
393                 db->bdi_name = bdbi_databases[i].name;
394                 bdb->bi_databases[i] = db;
395         }
396
397         bdb->bi_databases[i] = NULL;
398         bdb->bi_ndatabases = i;
399
400         /* get nextid */
401         rc = bdb_last_id( be, NULL );
402         if( rc != 0 ) {
403 #ifdef NEW_LOGGING
404                         LDAP_LOG( BACK_BDB, ERR, 
405                                 "bdb_db_open: last_id(%s) failed: %s (%d)\n", 
406                                 bdb->bi_dbenv_home, db_strerror(rc), rc );
407 #else
408                 Debug( LDAP_DEBUG_ANY,
409                         "bdb_db_open: last_id(%s) failed: %s (%d)\n",
410                         bdb->bi_dbenv_home, db_strerror(rc), rc );
411 #endif
412                 return rc;
413         }
414
415         /* <insert> open (and create) index databases */
416 #ifdef BDB_HIER
417         rc = bdb_build_tree( be );
418 #endif
419         return 0;
420 }
421
422 static int
423 bdb_db_close( BackendDB *be )
424 {
425         int rc;
426         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
427         struct bdb_db_info *db;
428 #ifdef SLAP_IDL_CACHE
429         bdb_idl_cache_entry_t *entry, *next_entry;
430 #endif
431
432         while( bdb->bi_ndatabases-- ) {
433                 db = bdb->bi_databases[bdb->bi_ndatabases];
434                 rc = db->bdi_db->close( db->bdi_db, 0 );
435                 /* Lower numbered names are not strdup'd */
436                 if( bdb->bi_ndatabases >= BDB_NDB )
437                         free( db->bdi_name );
438                 free( db );
439         }
440         free( bdb->bi_databases );
441         bdb_attr_index_destroy( bdb->bi_attrs );
442
443         bdb_cache_release_all (&bdb->bi_cache);
444
445 #ifdef SLAP_IDL_CACHE
446         ldap_pvt_thread_mutex_lock ( &bdb->bi_idl_tree_mutex );
447         entry = bdb->bi_idl_lru_head;
448         while ( entry != NULL ) {
449                 next_entry = entry->idl_lru_next;
450                 free( entry->idl );
451                 free( entry->kstr.bv_val );
452                 free( entry );
453                 entry = next_entry;
454         }
455         ldap_pvt_thread_mutex_unlock ( &bdb->bi_idl_tree_mutex );
456 #endif
457
458         return 0;
459 }
460
461 static int
462 bdb_db_destroy( BackendDB *be )
463 {
464         int rc;
465         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
466
467         /* close db environment */
468         if( bdb->bi_dbenv ) {
469                 /* force a checkpoint */
470                 rc = TXN_CHECKPOINT( bdb->bi_dbenv, 0, 0, DB_FORCE );
471                 if( rc != 0 ) {
472 #ifdef NEW_LOGGING
473                         LDAP_LOG( BACK_BDB, ERR, 
474                                 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
475                                 db_strerror(rc), rc, 0 );
476 #else
477                         Debug( LDAP_DEBUG_ANY,
478                                 "bdb_db_destroy: txn_checkpoint failed: %s (%d)\n",
479                                 db_strerror(rc), rc, 0 );
480 #endif
481                 }
482
483                 bdb_cache_release_all (&bdb->bi_cache);
484
485                 rc = bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
486                 bdb->bi_dbenv = NULL;
487                 if( rc != 0 ) {
488 #ifdef NEW_LOGGING
489                         LDAP_LOG( BACK_BDB, ERR, 
490                                 "bdb_db_destroy: close failed: %s (%d)\n", 
491                                 db_strerror(rc), rc, 0 );
492 #else
493                         Debug( LDAP_DEBUG_ANY,
494                                 "bdb_db_destroy: close failed: %s (%d)\n",
495                                 db_strerror(rc), rc, 0 );
496 #endif
497                         return rc;
498                 }
499         }
500
501         if( bdb->bi_dbenv_home ) ch_free( bdb->bi_dbenv_home );
502
503 #ifdef BDB_HIER
504         ldap_pvt_thread_rdwr_destroy( &bdb->bi_tree_rdwr );
505 #endif
506         ldap_pvt_thread_rdwr_destroy ( &bdb->bi_cache.c_rwlock );
507         ldap_pvt_thread_mutex_destroy( &bdb->bi_cache.lru_mutex );
508         ldap_pvt_thread_mutex_destroy( &bdb->bi_lastid_mutex );
509         ldap_pvt_thread_mutex_destroy( &bdb->bi_database_mutex );
510
511         ch_free( bdb );
512         be->be_private = NULL;
513
514         return 0;
515 }
516
517 #ifdef SLAPD_BDB_DYNAMIC
518 int back_bdb_LTX_init_module( int argc, char *argv[] ) {
519         BackendInfo bi;
520
521         memset( &bi, '\0', sizeof(bi) );
522         bi.bi_type = "bdb";
523         bi.bi_init = bdb_initialize;
524
525         backend_add( &bi );
526         return 0;
527 }
528 #endif /* SLAPD_BDB_DYNAMIC */
529
530 int
531 bdb_initialize(
532         BackendInfo     *bi
533 )
534 {
535         static char *controls[] = {
536                 LDAP_CONTROL_MANAGEDSAIT,
537                 LDAP_CONTROL_NOOP,
538 #ifdef LDAP_CONTROL_PAGEDRESULTS
539                 LDAP_CONTROL_PAGEDRESULTS,
540 #endif
541                 LDAP_CONTROL_VALUESRETURNFILTER,
542 #ifdef LDAP_CONTROL_SUBENTRIES
543                 LDAP_CONTROL_SUBENTRIES,
544 #endif
545 #ifdef LDAP_CLIENT_UPDATE
546                 LDAP_CONTROL_CLIENT_UPDATE,
547 #endif
548                 NULL
549         };
550
551         bi->bi_controls = controls;
552
553         /* initialize the underlying database system */
554 #ifdef NEW_LOGGING
555         LDAP_LOG( BACK_BDB, ENTRY, "bdb_db_initialize\n", 0, 0, 0 );
556 #else
557         Debug( LDAP_DEBUG_TRACE, "bdb_initialize: initialize BDB backend\n",
558                 0, 0, 0 );
559 #endif
560
561         {       /* version check */
562                 int major, minor, patch;
563                 char *version = db_version( &major, &minor, &patch );
564 #ifdef HAVE_EBCDIC
565                 char v2[1024];
566
567                 /* All our stdio does an ASCII to EBCDIC conversion on
568                  * the output. Strings from the BDB library are already
569                  * in EBCDIC; we have to go back and forth...
570                  */
571                 strcpy( v2, version );
572                 __etoa( v2 );
573                 version = v2;
574 #endif
575
576                 if( major != DB_VERSION_MAJOR ||
577                         minor != DB_VERSION_MINOR ||
578                         patch < DB_VERSION_PATCH )
579                 {
580 #ifdef NEW_LOGGING
581                         LDAP_LOG( BACK_BDB, ERR, 
582                                 "bdb_db_initialize: version mismatch: "
583                                 "\texpected: %s \tgot: %s\n", DB_VERSION_STRING, version, 0 );
584 #else
585                         Debug( LDAP_DEBUG_ANY,
586                                 "bdb_initialize: version mismatch\n"
587                                 "\texpected: " DB_VERSION_STRING "\n"
588                                 "\tgot: %s \n", version, 0, 0 );
589 #endif
590                 }
591
592 #ifdef NEW_LOGGING
593                 LDAP_LOG( BACK_BDB, DETAIL1, 
594                         "bdb_db_initialize: %s\n", version, 0, 0 );
595 #else
596                 Debug( LDAP_DEBUG_ANY, "bdb_initialize: %s\n",
597                         version, 0, 0 );
598 #endif
599         }
600
601         db_env_set_func_free( ber_memfree );
602         db_env_set_func_malloc( (db_malloc *)ber_memalloc );
603         db_env_set_func_realloc( (db_realloc *)ber_memrealloc );
604 #ifndef NO_THREAD
605         /* This is a no-op on a NO_THREAD build. Leave the default
606          * alone so that BDB will sleep on interprocess conflicts.
607          */
608         db_env_set_func_yield( ldap_pvt_thread_yield );
609 #endif
610
611         {
612                 static char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
613
614                 bdb_uuid.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ));
615                 bdb_uuid.bv_val = uuidbuf;
616         }
617
618         bi->bi_open = 0;
619         bi->bi_close = 0;
620         bi->bi_config = 0;
621         bi->bi_destroy = 0;
622
623         bi->bi_db_init = bdb_db_init;
624         bi->bi_db_config = bdb_db_config;
625         bi->bi_db_open = bdb_db_open;
626         bi->bi_db_close = bdb_db_close;
627         bi->bi_db_destroy = bdb_db_destroy;
628
629         bi->bi_op_add = bdb_add;
630         bi->bi_op_bind = bdb_bind;
631         bi->bi_op_compare = bdb_compare;
632         bi->bi_op_delete = bdb_delete;
633         bi->bi_op_modify = bdb_modify;
634         bi->bi_op_modrdn = bdb_modrdn;
635         bi->bi_op_search = bdb_search;
636
637         bi->bi_op_unbind = 0;
638
639 #ifdef LDAP_CLIENT_UPDATE
640         bi->bi_op_abandon = bdb_abandon;
641         bi->bi_op_cancel = bdb_cancel;
642 #else
643         bi->bi_op_abandon = 0;
644         bi->bi_op_cancel = 0;
645 #endif
646
647         bi->bi_extended = bdb_extended;
648
649 #if 1
650         /*
651          * these routines (and their callers) are not yet designed
652          * to work with transaction.  Using them may cause deadlock.
653          */
654         bi->bi_acl_group = bdb_group;
655         bi->bi_acl_attribute = bdb_attribute;
656 #else
657         bi->bi_acl_group = 0;
658         bi->bi_acl_attribute = 0;
659 #endif
660
661         bi->bi_chk_referrals = bdb_referrals;
662         bi->bi_operational = bdb_operational;
663         bi->bi_has_subordinates = bdb_hasSubordinates;
664         bi->bi_entry_release_rw = bdb_entry_release;
665
666         /*
667          * hooks for slap tools
668          */
669         bi->bi_tool_entry_open = bdb_tool_entry_open;
670         bi->bi_tool_entry_close = bdb_tool_entry_close;
671         bi->bi_tool_entry_first = bdb_tool_entry_next;
672         bi->bi_tool_entry_next = bdb_tool_entry_next;
673         bi->bi_tool_entry_get = bdb_tool_entry_get;
674         bi->bi_tool_entry_put = bdb_tool_entry_put;
675         bi->bi_tool_entry_reindex = bdb_tool_entry_reindex;
676         bi->bi_tool_sync = 0;
677
678         bi->bi_connection_init = 0;
679         bi->bi_connection_destroy = 0;
680
681         return 0;
682 }