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