1 /* back-mdb.h - mdb back-end header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2011 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>.
26 #define MDB_TOOL_IDL_CACHING 1
28 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
29 #define DN_ONE_PREFIX '%'
30 #define DN_SUBTREE_PREFIX '@'
34 #define MDB_ID2ENTRY 2
37 /* The default search IDL stack cache depth */
38 #define DEFAULT_SEARCH_STACK_DEPTH 16
40 /* The minimum we can function with */
41 #define MINIMUM_SEARCH_STACK_DEPTH 8
43 #define MDB_INDICES 128
45 #define MDB_MAXADS 65536
47 /* Default to 10MB max */
48 #define DEFAULT_MAPSIZE (10*1048576)
51 #define MDB_MONITOR_IDX
52 #endif /* LDAP_DEVEL */
54 typedef struct mdb_monitor_t {
56 struct berval mdm_ndn;
65 /* DB_ENV parameters */
66 /* The DB_ENV can be tuned via DB_CONFIG */
68 u_int32_t mi_dbenv_flags;
73 slap_mask_t mi_defaultmask;
75 struct mdb_attrinfo **mi_attrs;
76 void *mi_search_stack;
77 int mi_search_stack_depth;
81 u_int32_t mi_txn_cp_min;
82 u_int32_t mi_txn_cp_kbyte;
83 struct re_s *mi_txn_cp_task;
84 struct re_s *mi_index_task;
86 mdb_monitor_t mi_monitor;
88 #ifdef MDB_MONITOR_IDX
89 ldap_pvt_thread_mutex_t mi_idx_mutex;
91 #endif /* MDB_MONITOR_IDX */
94 #define MDB_IS_OPEN 0x01
95 #define MDB_OPEN_INDEX 0x02
96 #define MDB_DEL_INDEX 0x08
97 #define MDB_RE_OPEN 0x10
101 MDB_dbi mi_dbis[MDB_NDB];
102 AttributeDescription *mi_ads[MDB_MAXADS];
103 int mi_adxs[MDB_MAXADS];
106 #define mi_id2entry mi_dbis[MDB_ID2ENTRY]
107 #define mi_dn2id mi_dbis[MDB_DN2ID]
108 #define mi_ad2id mi_dbis[MDB_AD2ID]
110 typedef struct mdb_op_info {
116 #define MOI_READER 0x01
117 #define MOI_FREEIT 0x02
119 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
120 #define MDB_ID2DISK( src, dst ) \
121 do { int i0; ID tmp; unsigned char *_p; \
122 tmp = (src); _p = (unsigned char *)(dst); \
123 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
124 _p[i0] = tmp & 0xff; tmp >>= 8; \
128 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
129 #define MDB_DISK2ID( src, dst ) \
130 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
131 _p = (unsigned char *)(src); \
132 for ( i0=0; i0<sizeof(ID); i0++ ) { \
133 tmp <<= 8; tmp |= *_p++; \
139 /* for the cache of attribute information (which are indexed, etc.) */
140 typedef struct mdb_attrinfo {
141 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
142 slap_mask_t ai_indexmask; /* how the attr is indexed */
143 slap_mask_t ai_newmask; /* new settings to replace old mask */
144 #ifdef LDAP_COMP_MATCH
145 ComponentReference* ai_cr; /*component indexing*/
147 Avlnode *ai_root; /* for tools */
148 void *ai_flist; /* for tools */
149 void *ai_clist; /* for tools */
150 MDB_cursor *ai_cursor; /* for tools */
151 int ai_idx; /* position in AI array */
155 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
156 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
157 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
159 /* For slapindex to record which attrs in an entry belong to which
162 typedef struct AttrList {
163 struct AttrList *next;
171 typedef struct IndexRbody {
178 typedef struct IndexRec {
181 #define ir_ai iru.irb.ai
182 #define ir_attrs iru.irb.attrs
183 #define ir_tptr iru.irb.tptr
184 #define ir_i iru.irb.i
185 /* cache line alignment */
186 char pad[(sizeof(IndexRbody)+CACHELINE-1) & (!CACHELINE-1)];
190 #define MAXRDNS SLAP_LDAPDN_MAXLEN/4
192 #include "proto-mdb.h"
194 #endif /* _BACK_MDB_H_ */