]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/proto-bdb.h
ITS#3470 don't propagate error if hasSubordinates fails, it's not that
[openldap] / servers / slapd / back-bdb / proto-bdb.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2000-2005 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15
16 #ifndef _PROTO_BDB_H
17 #define _PROTO_BDB_H
18
19 LDAP_BEGIN_DECL
20
21 #ifdef BDB_HIER
22 #define BDB_SYMBOL(x)   LDAP_CONCAT(hdb_,x)
23 #define BDB_UCTYPE      "HDB"
24 #else
25 #define BDB_SYMBOL(x)   LDAP_CONCAT(bdb_,x)
26 #define BDB_UCTYPE      "BDB"
27 #endif
28
29 /*
30  * attr.c
31  */
32
33 #define bdb_attr_mask                           BDB_SYMBOL(attr_mask)
34 #define bdb_attr_index_config           BDB_SYMBOL(attr_index_config)
35 #define bdb_attr_index_destroy          BDB_SYMBOL(attr_index_destroy)
36
37 #ifdef LDAP_COMP_MATCH
38 #define bdb_attr_comp_ref                       BDB_SYMBOL(attr_comp_ref)
39 void bdb_attr_comp_ref( struct bdb_info *bdb,
40         AttributeDescription *desc,
41         ComponentReference **cr );
42 #endif
43
44 void bdb_attr_mask( struct bdb_info *bdb,
45         AttributeDescription *desc,
46         slap_mask_t *indexmask );
47
48 int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb,
49         const char *fname, int lineno,
50         int argc, char **argv ));
51
52 void bdb_attr_index_destroy LDAP_P(( Avlnode *tree ));
53
54 /*
55  * ctxcsn.c
56  */
57 #define bdb_csn_commit                          BDB_SYMBOL(csn_commit)
58 #define bdb_get_commit_csn                      BDB_SYMBOL(get_commit_csn)
59
60 int bdb_csn_commit LDAP_P(( Operation *op, SlapReply *rs, DB_TXN *tid,
61                                                 EntryInfo *ei, EntryInfo **suffix_ei, Entry **ctxcsn_e,
62                                                 int *ctxcsn_added, u_int32_t locker ));
63
64 int bdb_get_commit_csn LDAP_P(( Operation *op, SlapReply *rs,
65                                                 struct berval **search_context_csn,
66                                                 u_int32_t locker, DB_LOCK *ctxcsn_lock ));
67
68 /*
69  * dbcache.c
70  */
71 #define bdb_db_cache                            BDB_SYMBOL(db_cache)
72
73 int
74 bdb_db_cache(
75     Backend     *be,
76     const char *name,
77         DB **db );
78
79 /*
80  * dn2entry.c
81  */
82 #define bdb_dn2entry                            BDB_SYMBOL(dn2entry)
83
84 int bdb_dn2entry LDAP_P(( Operation *op, DB_TXN *tid,
85         struct berval *dn, EntryInfo **e, int matched,
86         u_int32_t locker, DB_LOCK *lock ));
87
88 /*
89  * dn2id.c
90  */
91 #define bdb_dn2id                                       BDB_SYMBOL(dn2id)
92 #define bdb_dn2id_add                           BDB_SYMBOL(dn2id_add)
93 #define bdb_dn2id_delete                        BDB_SYMBOL(dn2id_delete)
94 #define bdb_dn2id_children                      BDB_SYMBOL(dn2id_children)
95 #define bdb_dn2idl                                      BDB_SYMBOL(dn2idl)
96
97 int bdb_dn2id(
98         Operation *op,
99         DB_TXN *tid,
100         struct berval *dn,
101         EntryInfo *ei );
102
103 int bdb_dn2id_add(
104         Operation *op,
105         DB_TXN *tid,
106         EntryInfo *eip,
107         Entry *e );
108
109 int bdb_dn2id_delete(
110         Operation *op,
111         DB_TXN *tid,
112         EntryInfo *eip,
113         Entry *e );
114
115 int bdb_dn2id_children(
116         Operation *op,
117         DB_TXN *tid,
118         Entry *e );
119
120 int bdb_dn2idl(
121         Operation *op,
122         Entry *e,
123         ID *ids,
124         ID *stack );
125
126 #ifdef BDB_HIER
127 #define bdb_dn2id_parent                        BDB_SYMBOL(dn2id_parent)
128 #define bdb_dup_compare                         BDB_SYMBOL(dup_compare)
129 #define bdb_fix_dn                                      BDB_SYMBOL(fix_dn)
130
131 int bdb_dn2id_parent(
132         Operation *op,
133         DB_TXN *txn,
134         EntryInfo *ei,
135         ID *idp );
136
137 int bdb_dup_compare(
138         DB *db,
139         const DBT *usrkey,
140         const DBT *curkey );
141
142 int bdb_fix_dn( Entry *e, int checkit );
143 #endif
144
145
146 /*
147  * error.c
148  */
149 #define bdb_errcall                                     BDB_SYMBOL(errcall)
150
151 #if DB_VERSION_FULL < 0x04030000
152 void bdb_errcall( const char *pfx, char * msg );
153 #else
154 void bdb_errcall( const DB_ENV *env, const char *pfx, const char * msg );
155 #endif
156
157 #ifdef HAVE_EBCDIC
158 #define ebcdic_dberror                          BDB_SYMBOL(ebcdic_dberror)
159
160 char *ebcdic_dberror( int rc );
161 #define db_strerror(x)  ebcdic_dberror(x)
162 #endif
163
164 /*
165  * filterentry.c
166  */
167 #define bdb_filter_candidates           BDB_SYMBOL(filter_candidates)
168
169 int bdb_filter_candidates(
170         Operation *op,
171         Filter  *f,
172         ID *ids,
173         ID *tmp,
174         ID *stack );
175
176 /*
177  * id2entry.c
178  */
179 #define bdb_id2entry                            BDB_SYMBOL(id2entry)
180 #define bdb_id2entry_add                        BDB_SYMBOL(id2entry_add)
181 #define bdb_id2entry_update                     BDB_SYMBOL(id2entry_update)
182 #define bdb_id2entry_delete                     BDB_SYMBOL(id2entry_delete)
183
184 int bdb_id2entry_add(
185         BackendDB *be,
186         DB_TXN *tid,
187         Entry *e );
188
189 int bdb_id2entry_update(
190         BackendDB *be,
191         DB_TXN *tid,
192         Entry *e );
193
194 int bdb_id2entry_delete(
195         BackendDB *be,
196         DB_TXN *tid,
197         Entry *e);
198
199 #ifdef SLAP_ZONE_ALLOC
200 #else
201 int bdb_id2entry(
202         BackendDB *be,
203         DB_TXN *tid,
204         ID id,
205         Entry **e);
206 #endif
207
208 #define bdb_entry_free                          BDB_SYMBOL(entry_free)
209 #define bdb_entry_return                        BDB_SYMBOL(entry_return)
210 #define bdb_entry_release                       BDB_SYMBOL(entry_release)
211 #define bdb_entry_get                           BDB_SYMBOL(entry_get)
212
213 void bdb_entry_free ( Entry *e );
214 #ifdef SLAP_ZONE_ALLOC
215 int bdb_entry_return( struct bdb_info *bdb, Entry *e, int seqno );
216 #else
217 int bdb_entry_return( Entry *e );
218 #endif
219 BI_entry_release_rw bdb_entry_release;
220 BI_entry_get_rw bdb_entry_get;
221
222
223 /*
224  * idl.c
225  */
226
227 #define bdb_idl_cache_get                       BDB_SYMBOL(idl_cache_get)
228 #define bdb_idl_cache_put                       BDB_SYMBOL(idl_cache_put)
229 #define bdb_idl_cache_del                       BDB_SYMBOL(idl_cache_del)
230
231 int bdb_idl_cache_get(
232         struct bdb_info *bdb,
233         DB *db,
234         DBT *key,
235         ID *ids );
236
237 void
238 bdb_idl_cache_put(
239         struct bdb_info *bdb,
240         DB              *db,
241         DBT             *key,
242         ID              *ids,
243         int             rc );
244
245 void
246 bdb_idl_cache_del(
247         struct bdb_info *bdb,
248         DB              *db,
249         DBT             *key );
250
251 #define bdb_idl_first                           BDB_SYMBOL(idl_first)
252 #define bdb_idl_next                            BDB_SYMBOL(idl_next)
253 #define bdb_idl_search                          BDB_SYMBOL(idl_search)
254 #define bdb_idl_insert                          BDB_SYMBOL(idl_insert)
255 #define bdb_idl_intersection            BDB_SYMBOL(idl_intersection)
256 #define bdb_idl_union                           BDB_SYMBOL(idl_union)
257
258 #define bdb_idl_fetch_key                       BDB_SYMBOL(idl_fetch_key)
259 #define bdb_idl_insert_key                      BDB_SYMBOL(idl_insert_key)
260 #define bdb_idl_delete_key                      BDB_SYMBOL(idl_delete_key)
261
262 unsigned bdb_idl_search( ID *ids, ID id );
263
264 int bdb_idl_fetch_key(
265         BackendDB       *be,
266         DB                      *db,
267         DB_TXN          *tid,
268         DBT                     *key,
269         ID                      *ids,
270         DBC                     **saved_cursor,
271         int                     get_flag );
272
273 int bdb_idl_insert( ID *ids, ID id );
274
275 int bdb_idl_insert_key(
276         BackendDB *be,
277         DB *db,
278         DB_TXN *txn,
279         DBT *key,
280         ID id );
281
282 int bdb_idl_delete_key(
283         BackendDB *be,
284         DB *db,
285         DB_TXN *txn,
286         DBT *key,
287         ID id );
288
289 int
290 bdb_idl_intersection(
291         ID *a,
292         ID *b );
293
294 int
295 bdb_idl_union(
296         ID *a,
297         ID *b );
298
299 ID bdb_idl_first( ID *ids, ID *cursor );
300 ID bdb_idl_next( ID *ids, ID *cursor );
301
302
303 #define bdb_bt_compare                          BDB_SYMBOL(bt_compare)
304
305 int bdb_bt_compare(
306         DB *db,
307         const DBT *a,
308         const DBT *b );
309
310
311 /*
312  * index.c
313  */
314 #define bdb_index_is_indexed            BDB_SYMBOL(index_is_indexed)
315 #define bdb_index_param                         BDB_SYMBOL(index_param)
316 #define bdb_index_values                        BDB_SYMBOL(index_values)
317 #define bdb_index_entry                         BDB_SYMBOL(index_entry)
318
319 extern int
320 bdb_index_is_indexed LDAP_P((
321         Backend *be,
322         AttributeDescription *desc ));
323
324 extern int
325 bdb_index_param LDAP_P((
326         Backend *be,
327         AttributeDescription *desc,
328         int ftype,
329         DB **db,
330         slap_mask_t *mask,
331         struct berval *prefix ));
332
333 extern int
334 bdb_index_values LDAP_P((
335         Operation *op,
336         DB_TXN *txn,
337         AttributeDescription *desc,
338         BerVarray vals,
339         ID id,
340         int opid ));
341
342 int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e ));
343
344 #define bdb_index_entry_add(op,t,e) \
345         bdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
346 #define bdb_index_entry_del(op,t,e) \
347         bdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
348
349 /*
350  * init.c
351  */
352 #define bdb_uuid                                        BDB_SYMBOL(uuid)
353
354 extern struct berval bdb_uuid;
355
356 /*
357  * key.c
358  */
359 #define bdb_key_read                            BDB_SYMBOL(key_read)
360 #define bdb_key_change                          BDB_SYMBOL(key_change)
361
362 extern int
363 bdb_key_read(
364     Backend     *be,
365         DB *db,
366         DB_TXN *txn,
367     struct berval *k,
368         ID *ids,
369     DBC **saved_cursor,
370         int get_flags );
371
372 extern int
373 bdb_key_change(
374     Backend      *be,
375     DB *db,
376         DB_TXN *txn,
377     struct berval *k,
378     ID id,
379     int op );
380         
381 /*
382  * nextid.c
383  */
384 #define bdb_next_id                                     BDB_SYMBOL(next_id)
385 #define bdb_last_id                                     BDB_SYMBOL(last_id)
386
387 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
388 int bdb_last_id( BackendDB *be, DB_TXN *tid );
389
390 /*
391  * modify.c
392  */
393 #define bdb_modify_internal                     BDB_SYMBOL(modify_internal)
394
395 int bdb_modify_internal(
396         Operation *op,
397         DB_TXN *tid,
398         Modifications *modlist,
399         Entry *e,
400         const char **text,
401         char *textbuf,
402         size_t textlen );
403
404
405 /*
406  * cache.c
407  */
408 #define bdb_cache_entry_db_unlock       BDB_SYMBOL(cache_entry_db_unlock)
409
410 #define bdb_cache_entryinfo_lock(e) \
411         ldap_pvt_thread_mutex_lock( &(e)->bei_kids_mutex )
412 #define bdb_cache_entryinfo_unlock(e) \
413         ldap_pvt_thread_mutex_unlock( &(e)->bei_kids_mutex )
414
415 /* What a mess. Hopefully the current cache scheme will stabilize
416  * and we can trim out all of this stuff.
417  */
418 #if 0
419 void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e,
420         int rw, DB_LOCK *lock );
421 #else
422 #define bdb_cache_return_entry_rw( env, cache, e, rw, lock ) \
423         bdb_cache_entry_db_unlock( env, lock )
424 #define bdb_cache_return_entry( env, lock ) \
425         bdb_cache_entry_db_unlock( env, lock )
426 #endif
427 #define bdb_cache_return_entry_r(env, c, e, l) \
428         bdb_cache_return_entry_rw((env), (c), (e), 0, (l))
429 #define bdb_cache_return_entry_w(env, c, e, l) \
430         bdb_cache_return_entry_rw((env), (c), (e), 1, (l))
431 #if 0
432 void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
433 #else
434 #define bdb_unlocked_cache_return_entry_rw( a, b, c )
435 #endif
436 #define bdb_unlocked_cache_return_entry_r( c, e ) \
437         bdb_unlocked_cache_return_entry_rw((c), (e), 0)
438 #define bdb_unlocked_cache_return_entry_w( c, e ) \
439         bdb_unlocked_cache_return_entry_rw((c), (e), 1)
440
441 #define bdb_cache_add                           BDB_SYMBOL(cache_add)
442 #define bdb_cache_children                      BDB_SYMBOL(cache_children)
443 #define bdb_cache_delete                        BDB_SYMBOL(cache_delete)
444 #define bdb_cache_delete_cleanup        BDB_SYMBOL(cache_delete_cleanup)
445 #define bdb_cache_find_id                       BDB_SYMBOL(cache_find_id)
446 #define bdb_cache_find_info                     BDB_SYMBOL(cache_find_info)
447 #define bdb_cache_find_ndn                      BDB_SYMBOL(cache_find_ndn)
448 #define bdb_cache_modify                        BDB_SYMBOL(cache_modify)
449 #define bdb_cache_modrdn                        BDB_SYMBOL(cache_modrdn)
450 #define bdb_cache_release_all           BDB_SYMBOL(cache_release_all)
451 #define bdb_cache_delete_entry          BDB_SYMBOL(cache_delete_entry)
452
453 int bdb_cache_children(
454         Operation *op,
455         DB_TXN *txn,
456         Entry *e
457 );
458 int bdb_cache_add(
459         struct bdb_info *bdb,
460         EntryInfo *pei,
461         Entry   *e,
462         struct berval *nrdn,
463         u_int32_t locker
464 );
465 int bdb_cache_modrdn(
466         Entry   *e,
467         struct berval *nrdn,
468         Entry   *new,
469         EntryInfo *ein,
470         DB_ENV *env,
471         u_int32_t locker,
472         DB_LOCK *lock
473 );
474 int bdb_cache_modify(
475         Entry *e,
476         Attribute *newAttrs,
477         DB_ENV *env,
478         u_int32_t locker,
479         DB_LOCK *lock
480 );
481 int bdb_cache_find_ndn(
482         Operation *op,
483         DB_TXN  *txn,
484         struct berval   *ndn,
485         EntryInfo       **res
486 );
487 EntryInfo * bdb_cache_find_info(
488         struct bdb_info *bdb,
489         ID id
490 );
491 int bdb_cache_find_id(
492         Operation *op,
493         DB_TXN  *tid,
494         ID              id,
495         EntryInfo **eip,
496         int     islocked,
497         u_int32_t       locker,
498         DB_LOCK         *lock
499 );
500 int bdb_cache_delete(
501         Cache   *cache,
502         Entry   *e,
503         DB_ENV  *env,
504         u_int32_t locker,
505         DB_LOCK *lock
506 );
507 void bdb_cache_delete_cleanup(
508         Cache   *cache,
509         EntryInfo *ei
510 );
511 void bdb_cache_release_all( Cache *cache );
512 void bdb_cache_delete_entry(
513         struct bdb_info *bdb,
514         EntryInfo *ei,
515         u_int32_t locker,
516         DB_LOCK *lock
517 );
518
519 #ifdef BDB_HIER
520 int hdb_cache_load(
521         struct bdb_info *bdb,
522         EntryInfo *ei,
523         EntryInfo **res
524 );
525 #endif
526
527 #define bdb_cache_entry_db_relock               BDB_SYMBOL(cache_entry_db_relock)
528 int bdb_cache_entry_db_relock(
529         DB_ENV *env,
530         u_int32_t locker,
531         EntryInfo *ei,
532         int rw,
533         int tryOnly,
534         DB_LOCK *lock );
535
536 int bdb_cache_entry_db_unlock(
537         DB_ENV *env,
538         DB_LOCK *lock );
539
540 #ifdef BDB_REUSE_LOCKERS
541
542 #define bdb_locker_id                           BDB_SYMBOL(locker_id)
543 int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
544
545 #define LOCK_ID_FREE(env, locker)
546 #define LOCK_ID(env, locker)    bdb_locker_id(op, env, locker)
547
548 #else
549
550 #define LOCK_ID_FREE(env, locker)       XLOCK_ID_FREE(env, locker)
551 #define LOCK_ID(env, locker)            XLOCK_ID(env, locker)
552
553 #endif
554
555 /*
556  * search.c
557  */
558
559 #define bdb_abandon                                     BDB_SYMBOL(abandon)
560 #define bdb_cancel                                      BDB_SYMBOL(cancel)
561 #define bdb_do_search                           BDB_SYMBOL(do_search)
562 #define bdb_psearch                             BDB_SYMBOL(psearch)
563
564 BI_op_abandon bdb_abandon;
565 BI_op_cancel bdb_cancel;
566
567 int bdb_psearch(
568         Operation       *op,
569         SlapReply       *rs,
570         Operation       *ps_op,
571         Entry           *entry,
572         int             psearch_type
573 );
574
575 int bdb_do_search(
576         Operation       *op,
577         SlapReply       *rs,
578         Operation       *ps_op,
579         Entry           *entry,
580         int             psearch_type
581 );
582
583 /*
584  * trans.c
585  */
586 #define bdb_trans_backoff                       BDB_SYMBOL(trans_backoff)
587
588 void
589 bdb_trans_backoff( int num_retries );
590
591 /*
592  * former external.h
593  */
594
595 #define bdb_back_initialize             BDB_SYMBOL(back_initialize)
596 #define bdb_db_config                   BDB_SYMBOL(db_config)
597 #define bdb_add                         BDB_SYMBOL(add)
598 #define bdb_bind                        BDB_SYMBOL(bind)
599 #define bdb_compare                     BDB_SYMBOL(compare)
600 #define bdb_delete                      BDB_SYMBOL(delete)
601 #define bdb_modify                      BDB_SYMBOL(modify)
602 #define bdb_modrdn                      BDB_SYMBOL(modrdn)
603 #define bdb_search                      BDB_SYMBOL(search)
604 #define bdb_extended                    BDB_SYMBOL(extended)
605 #define bdb_referrals                   BDB_SYMBOL(referrals)
606 #define bdb_operational                 BDB_SYMBOL(operational)
607 #define bdb_hasSubordinates             BDB_SYMBOL(hasSubordinates)
608 #define bdb_tool_entry_open             BDB_SYMBOL(tool_entry_open)
609 #define bdb_tool_entry_close            BDB_SYMBOL(tool_entry_close)
610 #define bdb_tool_entry_next             BDB_SYMBOL(tool_entry_next)
611 #define bdb_tool_entry_get              BDB_SYMBOL(tool_entry_get)
612 #define bdb_tool_entry_put              BDB_SYMBOL(tool_entry_put)
613 #define bdb_tool_entry_reindex          BDB_SYMBOL(tool_entry_reindex)
614 #define bdb_tool_dn2id_get              BDB_SYMBOL(tool_dn2id_get)
615 #define bdb_tool_id2entry_get           BDB_SYMBOL(tool_id2entry_get)
616 #define bdb_tool_entry_modify           BDB_SYMBOL(tool_entry_modify)
617
618 extern BI_init                          bdb_back_initialize;
619
620 extern BI_db_config                     bdb_db_config;
621
622 extern BI_op_add                        bdb_add;
623 extern BI_op_bind                       bdb_bind;
624 extern BI_op_compare                    bdb_compare;
625 extern BI_op_delete                     bdb_delete;
626 extern BI_op_modify                     bdb_modify;
627 extern BI_op_modrdn                     bdb_modrdn;
628 extern BI_op_search                     bdb_search;
629 extern BI_op_extended                   bdb_extended;
630
631 extern BI_chk_referrals                 bdb_referrals;
632
633 extern BI_operational                   bdb_operational;
634
635 extern BI_has_subordinates              bdb_hasSubordinates;
636
637 /* tools.c */
638 extern BI_tool_entry_open               bdb_tool_entry_open;
639 extern BI_tool_entry_close              bdb_tool_entry_close;
640 extern BI_tool_entry_next               bdb_tool_entry_next;
641 extern BI_tool_entry_get                bdb_tool_entry_get;
642 extern BI_tool_entry_put                bdb_tool_entry_put;
643 extern BI_tool_entry_reindex            bdb_tool_entry_reindex;
644 extern BI_tool_dn2id_get                bdb_tool_dn2id_get;
645 extern BI_tool_id2entry_get             bdb_tool_id2entry_get;
646 extern BI_tool_entry_modify             bdb_tool_entry_modify;
647
648 LDAP_END_DECL
649
650 #endif /* _PROTO_BDB_H */