1 /* back-mdb.h - mdb back-end header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2000-2017 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 #undef MDB_TOOL_IDL_CACHING /* currently no perf gain */
28 #define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
29 #define DN_ONE_PREFIX '%'
30 #define DN_SUBTREE_PREFIX '@'
34 #define MDB_ID2ENTRY 2
38 /* The default search IDL stack cache depth */
39 #define DEFAULT_SEARCH_STACK_DEPTH 16
41 /* The minimum we can function with */
42 #define MINIMUM_SEARCH_STACK_DEPTH 8
44 #define MDB_INDICES 128
46 #define MDB_MAXADS 65536
48 /* Default to 10MB max */
49 #define DEFAULT_MAPSIZE (10*1048576)
51 /* Most users will never see this */
52 #define DEFAULT_RTXN_SIZE 10000
55 #define MDB_MONITOR_IDX
58 typedef struct mdb_monitor_t {
60 struct berval mdm_ndn;
69 /* DB_ENV parameters */
71 uint32_t mi_dbenv_flags;
76 size_t mi_maxentrysize;
78 slap_mask_t mi_defaultmask;
80 struct mdb_attrinfo **mi_attrs;
81 void *mi_search_stack;
82 int mi_search_stack_depth;
85 uint32_t mi_rtxn_size;
87 uint32_t mi_txn_cp_min;
88 uint32_t mi_txn_cp_kbyte;
90 struct re_s *mi_txn_cp_task;
91 struct re_s *mi_index_task;
93 mdb_monitor_t mi_monitor;
95 #ifdef MDB_MONITOR_IDX
96 ldap_pvt_thread_mutex_t mi_idx_mutex;
98 #endif /* MDB_MONITOR_IDX */
101 #define MDB_IS_OPEN 0x01
102 #define MDB_OPEN_INDEX 0x02
103 #define MDB_DEL_INDEX 0x08
104 #define MDB_RE_OPEN 0x10
105 #define MDB_NEED_UPGRADE 0x20
109 unsigned mi_multi_hi;
110 /* more than this many values in an attr goes
111 * into a separate DB */
112 unsigned mi_multi_lo;
113 /* less than this many values in an attr goes
114 * back into main blob */
116 MDB_dbi mi_dbis[MDB_NDB];
117 AttributeDescription *mi_ads[MDB_MAXADS];
118 int mi_adxs[MDB_MAXADS];
121 #define mi_id2entry mi_dbis[MDB_ID2ENTRY]
122 #define mi_dn2id mi_dbis[MDB_DN2ID]
123 #define mi_ad2id mi_dbis[MDB_AD2ID]
124 #define mi_id2val mi_dbis[MDB_ID2VAL]
126 typedef struct mdb_op_info {
132 #define MOI_READER 0x01
133 #define MOI_FREEIT 0x02
134 #define MOI_KEEPER 0x04
138 /* for the cache of attribute information (which are indexed, etc.) */
139 typedef struct mdb_attrinfo {
140 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
141 slap_mask_t ai_indexmask; /* how the attr is indexed */
142 slap_mask_t ai_newmask; /* new settings to replace old mask */
143 #ifdef LDAP_COMP_MATCH
144 ComponentReference* ai_cr; /*component indexing*/
146 TAvlnode *ai_root; /* for tools */
147 MDB_cursor *ai_cursor; /* for tools */
148 int ai_idx; /* position in AI array */
152 /* tool threaded indexer state */
153 typedef struct mdb_attrixinfo {
160 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
161 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
162 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
164 /* For slapindex to record which attrs in an entry belong to which
167 typedef struct AttrList {
168 struct AttrList *next;
176 #if defined(__i386) || defined(__x86_64)
177 #define MISALIGNED_OK 1
179 #define ALIGNER (sizeof(size_t)-1)
182 typedef struct IndexRbody {
189 typedef struct IndexRec {
192 #define ir_ai iru.irb.ai
193 #define ir_attrs iru.irb.attrs
194 #define ir_tptr iru.irb.tptr
195 #define ir_i iru.irb.i
196 /* cache line alignment */
197 char pad[(sizeof(IndexRbody)+CACHELINE-1) & (!CACHELINE-1)];
201 #define MAXRDNS SLAP_LDAPDN_MAXLEN/4
203 #include "proto-mdb.h"
205 #endif /* _BACK_MDB_H_ */