]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/proto-bdb.h
Start removing custom sort functions from hdb
[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 #if 0
304 #define bdb_bt_compare                          BDB_SYMBOL(bt_compare)
305
306 int bdb_bt_compare(
307         DB *db,
308         const DBT *a,
309         const DBT *b );
310 #endif
311
312
313 /*
314  * index.c
315  */
316 #define bdb_index_is_indexed            BDB_SYMBOL(index_is_indexed)
317 #define bdb_index_param                         BDB_SYMBOL(index_param)
318 #define bdb_index_values                        BDB_SYMBOL(index_values)
319 #define bdb_index_entry                         BDB_SYMBOL(index_entry)
320
321 extern int
322 bdb_index_is_indexed LDAP_P((
323         Backend *be,
324         AttributeDescription *desc ));
325
326 extern int
327 bdb_index_param LDAP_P((
328         Backend *be,
329         AttributeDescription *desc,
330         int ftype,
331         DB **db,
332         slap_mask_t *mask,
333         struct berval *prefix ));
334
335 extern int
336 bdb_index_values LDAP_P((
337         Operation *op,
338         DB_TXN *txn,
339         AttributeDescription *desc,
340         BerVarray vals,
341         ID id,
342         int opid ));
343
344 int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e ));
345
346 #define bdb_index_entry_add(op,t,e) \
347         bdb_index_entry((op),(t),SLAP_INDEX_ADD_OP,(e))
348 #define bdb_index_entry_del(op,t,e) \
349         bdb_index_entry((op),(t),SLAP_INDEX_DELETE_OP,(e))
350
351 /*
352  * init.c
353  */
354 #define bdb_uuid                                        BDB_SYMBOL(uuid)
355
356 extern struct berval bdb_uuid;
357
358 /*
359  * key.c
360  */
361 #define bdb_key_read                            BDB_SYMBOL(key_read)
362 #define bdb_key_change                          BDB_SYMBOL(key_change)
363
364 extern int
365 bdb_key_read(
366     Backend     *be,
367         DB *db,
368         DB_TXN *txn,
369     struct berval *k,
370         ID *ids,
371     DBC **saved_cursor,
372         int get_flags );
373
374 extern int
375 bdb_key_change(
376     Backend      *be,
377     DB *db,
378         DB_TXN *txn,
379     struct berval *k,
380     ID id,
381     int op );
382         
383 /*
384  * nextid.c
385  */
386 #define bdb_next_id                                     BDB_SYMBOL(next_id)
387 #define bdb_last_id                                     BDB_SYMBOL(last_id)
388
389 int bdb_next_id( BackendDB *be, DB_TXN *tid, ID *id );
390 int bdb_last_id( BackendDB *be, DB_TXN *tid );
391
392 /*
393  * modify.c
394  */
395 #define bdb_modify_internal                     BDB_SYMBOL(modify_internal)
396
397 int bdb_modify_internal(
398         Operation *op,
399         DB_TXN *tid,
400         Modifications *modlist,
401         Entry *e,
402         const char **text,
403         char *textbuf,
404         size_t textlen );
405
406
407 /*
408  * cache.c
409  */
410 #define bdb_cache_entry_db_unlock       BDB_SYMBOL(cache_entry_db_unlock)
411
412 #define bdb_cache_entryinfo_lock(e) \
413         ldap_pvt_thread_mutex_lock( &(e)->bei_kids_mutex )
414 #define bdb_cache_entryinfo_unlock(e) \
415         ldap_pvt_thread_mutex_unlock( &(e)->bei_kids_mutex )
416
417 /* What a mess. Hopefully the current cache scheme will stabilize
418  * and we can trim out all of this stuff.
419  */
420 #if 0
421 void bdb_cache_return_entry_rw( DB_ENV *env, Cache *cache, Entry *e,
422         int rw, DB_LOCK *lock );
423 #else
424 #define bdb_cache_return_entry_rw( env, cache, e, rw, lock ) \
425         bdb_cache_entry_db_unlock( env, lock )
426 #define bdb_cache_return_entry( env, lock ) \
427         bdb_cache_entry_db_unlock( env, lock )
428 #endif
429 #define bdb_cache_return_entry_r(env, c, e, l) \
430         bdb_cache_return_entry_rw((env), (c), (e), 0, (l))
431 #define bdb_cache_return_entry_w(env, c, e, l) \
432         bdb_cache_return_entry_rw((env), (c), (e), 1, (l))
433 #if 0
434 void bdb_unlocked_cache_return_entry_rw( Cache *cache, Entry *e, int rw );
435 #else
436 #define bdb_unlocked_cache_return_entry_rw( a, b, c )
437 #endif
438 #define bdb_unlocked_cache_return_entry_r( c, e ) \
439         bdb_unlocked_cache_return_entry_rw((c), (e), 0)
440 #define bdb_unlocked_cache_return_entry_w( c, e ) \
441         bdb_unlocked_cache_return_entry_rw((c), (e), 1)
442
443 #define bdb_cache_add                           BDB_SYMBOL(cache_add)
444 #define bdb_cache_children                      BDB_SYMBOL(cache_children)
445 #define bdb_cache_delete                        BDB_SYMBOL(cache_delete)
446 #define bdb_cache_delete_cleanup        BDB_SYMBOL(cache_delete_cleanup)
447 #define bdb_cache_find_id                       BDB_SYMBOL(cache_find_id)
448 #define bdb_cache_find_info                     BDB_SYMBOL(cache_find_info)
449 #define bdb_cache_find_ndn                      BDB_SYMBOL(cache_find_ndn)
450 #define bdb_cache_modify                        BDB_SYMBOL(cache_modify)
451 #define bdb_cache_modrdn                        BDB_SYMBOL(cache_modrdn)
452 #define bdb_cache_release_all           BDB_SYMBOL(cache_release_all)
453 #define bdb_cache_delete_entry          BDB_SYMBOL(cache_delete_entry)
454
455 int bdb_cache_children(
456         Operation *op,
457         DB_TXN *txn,
458         Entry *e
459 );
460 int bdb_cache_add(
461         struct bdb_info *bdb,
462         EntryInfo *pei,
463         Entry   *e,
464         struct berval *nrdn,
465         u_int32_t locker
466 );
467 int bdb_cache_modrdn(
468         Entry   *e,
469         struct berval *nrdn,
470         Entry   *new,
471         EntryInfo *ein,
472         DB_ENV *env,
473         u_int32_t locker,
474         DB_LOCK *lock
475 );
476 int bdb_cache_modify(
477         Entry *e,
478         Attribute *newAttrs,
479         DB_ENV *env,
480         u_int32_t locker,
481         DB_LOCK *lock
482 );
483 int bdb_cache_find_ndn(
484         Operation *op,
485         DB_TXN  *txn,
486         struct berval   *ndn,
487         EntryInfo       **res
488 );
489 EntryInfo * bdb_cache_find_info(
490         struct bdb_info *bdb,
491         ID id
492 );
493 int bdb_cache_find_id(
494         Operation *op,
495         DB_TXN  *tid,
496         ID              id,
497         EntryInfo **eip,
498         int     islocked,
499         u_int32_t       locker,
500         DB_LOCK         *lock
501 );
502 int bdb_cache_delete(
503         Cache   *cache,
504         Entry   *e,
505         DB_ENV  *env,
506         u_int32_t locker,
507         DB_LOCK *lock
508 );
509 void bdb_cache_delete_cleanup(
510         Cache   *cache,
511         EntryInfo *ei
512 );
513 void bdb_cache_release_all( Cache *cache );
514 void bdb_cache_delete_entry(
515         struct bdb_info *bdb,
516         EntryInfo *ei,
517         u_int32_t locker,
518         DB_LOCK *lock
519 );
520
521 #ifdef BDB_HIER
522 int hdb_cache_load(
523         struct bdb_info *bdb,
524         EntryInfo *ei,
525         EntryInfo **res
526 );
527 #endif
528
529 #define bdb_cache_entry_db_relock               BDB_SYMBOL(cache_entry_db_relock)
530 int bdb_cache_entry_db_relock(
531         DB_ENV *env,
532         u_int32_t locker,
533         EntryInfo *ei,
534         int rw,
535         int tryOnly,
536         DB_LOCK *lock );
537
538 int bdb_cache_entry_db_unlock(
539         DB_ENV *env,
540         DB_LOCK *lock );
541
542 #ifdef BDB_REUSE_LOCKERS
543
544 #define bdb_locker_id                           BDB_SYMBOL(locker_id)
545 int bdb_locker_id( Operation *op, DB_ENV *env, int *locker );
546
547 #define LOCK_ID_FREE(env, locker)
548 #define LOCK_ID(env, locker)    bdb_locker_id(op, env, locker)
549
550 #else
551
552 #define LOCK_ID_FREE(env, locker)       XLOCK_ID_FREE(env, locker)
553 #define LOCK_ID(env, locker)            XLOCK_ID(env, locker)
554
555 #endif
556
557 /*
558  * search.c
559  */
560
561 #define bdb_abandon                                     BDB_SYMBOL(abandon)
562 #define bdb_cancel                                      BDB_SYMBOL(cancel)
563 #define bdb_do_search                           BDB_SYMBOL(do_search)
564 #define bdb_psearch                             BDB_SYMBOL(psearch)
565
566 BI_op_abandon bdb_abandon;
567 BI_op_cancel bdb_cancel;
568
569 int bdb_psearch(
570         Operation       *op,
571         SlapReply       *rs,
572         Operation       *ps_op,
573         Entry           *entry,
574         int             psearch_type
575 );
576
577 int bdb_do_search(
578         Operation       *op,
579         SlapReply       *rs,
580         Operation       *ps_op,
581         Entry           *entry,
582         int             psearch_type
583 );
584
585 /*
586  * trans.c
587  */
588 #define bdb_trans_backoff                       BDB_SYMBOL(trans_backoff)
589
590 void
591 bdb_trans_backoff( int num_retries );
592
593 /*
594  * former external.h
595  */
596
597 #define bdb_back_initialize             BDB_SYMBOL(back_initialize)
598 #define bdb_db_config                   BDB_SYMBOL(db_config)
599 #define bdb_add                         BDB_SYMBOL(add)
600 #define bdb_bind                        BDB_SYMBOL(bind)
601 #define bdb_compare                     BDB_SYMBOL(compare)
602 #define bdb_delete                      BDB_SYMBOL(delete)
603 #define bdb_modify                      BDB_SYMBOL(modify)
604 #define bdb_modrdn                      BDB_SYMBOL(modrdn)
605 #define bdb_search                      BDB_SYMBOL(search)
606 #define bdb_extended                    BDB_SYMBOL(extended)
607 #define bdb_referrals                   BDB_SYMBOL(referrals)
608 #define bdb_operational                 BDB_SYMBOL(operational)
609 #define bdb_hasSubordinates             BDB_SYMBOL(hasSubordinates)
610 #define bdb_tool_entry_open             BDB_SYMBOL(tool_entry_open)
611 #define bdb_tool_entry_close            BDB_SYMBOL(tool_entry_close)
612 #define bdb_tool_entry_next             BDB_SYMBOL(tool_entry_next)
613 #define bdb_tool_entry_get              BDB_SYMBOL(tool_entry_get)
614 #define bdb_tool_entry_put              BDB_SYMBOL(tool_entry_put)
615 #define bdb_tool_entry_reindex          BDB_SYMBOL(tool_entry_reindex)
616 #define bdb_tool_dn2id_get              BDB_SYMBOL(tool_dn2id_get)
617 #define bdb_tool_id2entry_get           BDB_SYMBOL(tool_id2entry_get)
618 #define bdb_tool_entry_modify           BDB_SYMBOL(tool_entry_modify)
619
620 extern BI_init                          bdb_back_initialize;
621
622 extern BI_db_config                     bdb_db_config;
623
624 extern BI_op_add                        bdb_add;
625 extern BI_op_bind                       bdb_bind;
626 extern BI_op_compare                    bdb_compare;
627 extern BI_op_delete                     bdb_delete;
628 extern BI_op_modify                     bdb_modify;
629 extern BI_op_modrdn                     bdb_modrdn;
630 extern BI_op_search                     bdb_search;
631 extern BI_op_extended                   bdb_extended;
632
633 extern BI_chk_referrals                 bdb_referrals;
634
635 extern BI_operational                   bdb_operational;
636
637 extern BI_has_subordinates              bdb_hasSubordinates;
638
639 /* tools.c */
640 extern BI_tool_entry_open               bdb_tool_entry_open;
641 extern BI_tool_entry_close              bdb_tool_entry_close;
642 extern BI_tool_entry_next               bdb_tool_entry_next;
643 extern BI_tool_entry_get                bdb_tool_entry_get;
644 extern BI_tool_entry_put                bdb_tool_entry_put;
645 extern BI_tool_entry_reindex            bdb_tool_entry_reindex;
646 extern BI_tool_dn2id_get                bdb_tool_dn2id_get;
647 extern BI_tool_id2entry_get             bdb_tool_id2entry_get;
648 extern BI_tool_entry_modify             bdb_tool_entry_modify;
649
650 LDAP_END_DECL
651
652 #endif /* _PROTO_BDB_H */