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 DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
27 #define DN_ONE_PREFIX '%'
28 #define DN_SUBTREE_PREFIX '@'
32 #define MDB_ID2ENTRY 2
35 /* The default search IDL stack cache depth */
36 #define DEFAULT_SEARCH_STACK_DEPTH 16
38 /* The minimum we can function with */
39 #define MINIMUM_SEARCH_STACK_DEPTH 8
41 #define MDB_INDICES 128
43 /* Default to 10MB max */
44 #define DEFAULT_MAPSIZE (10*1048576)
47 #define MDB_MONITOR_IDX
48 #endif /* LDAP_DEVEL */
50 typedef struct mdb_monitor_t {
52 struct berval mdm_ndn;
61 /* DB_ENV parameters */
62 /* The DB_ENV can be tuned via DB_CONFIG */
64 u_int32_t mi_dbenv_flags;
69 slap_mask_t mi_defaultmask;
70 struct mdb_attrinfo **mi_attrs;
72 void *mi_search_stack;
73 int mi_search_stack_depth;
76 u_int32_t mi_txn_cp_min;
77 u_int32_t mi_txn_cp_kbyte;
78 struct re_s *mi_txn_cp_task;
79 struct re_s *mi_index_task;
81 mdb_monitor_t mi_monitor;
83 #ifdef MDB_MONITOR_IDX
84 ldap_pvt_thread_mutex_t mi_idx_mutex;
86 #endif /* MDB_MONITOR_IDX */
89 #define MDB_IS_OPEN 0x01
90 #define MDB_OPEN_INDEX 0x02
91 #define MDB_DEL_INDEX 0x08
92 #define MDB_RE_OPEN 0x10
94 MDB_dbi mi_dbis[MDB_NDB];
97 #define mi_id2entry mi_dbis[MDB_ID2ENTRY]
98 #define mi_dn2id mi_dbis[MDB_DN2ID]
99 #define mi_ad2id mi_dbis[MDB_AD2ID]
106 #define MOI_DONTFREE 1
108 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
109 #define MDB_ID2DISK( src, dst ) \
110 do { int i0; ID tmp; unsigned char *_p; \
111 tmp = (src); _p = (unsigned char *)(dst); \
112 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
113 _p[i0] = tmp & 0xff; tmp >>= 8; \
117 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
118 #define MDB_DISK2ID( src, dst ) \
119 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
120 _p = (unsigned char *)(src); \
121 for ( i0=0; i0<sizeof(ID); i0++ ) { \
122 tmp <<= 8; tmp |= *_p++; \
128 /* for the cache of attribute information (which are indexed, etc.) */
129 typedef struct mdb_attrinfo {
130 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
131 slap_mask_t ai_indexmask; /* how the attr is indexed */
132 slap_mask_t ai_newmask; /* new settings to replace old mask */
133 #ifdef LDAP_COMP_MATCH
134 ComponentReference* ai_cr; /*component indexing*/
136 int ai_idx; /* position in AI array */
140 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
141 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
142 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
144 /* For slapindex to record which attrs in an entry belong to which
147 typedef struct AttrList {
148 struct AttrList *next;
152 typedef struct IndexRec {
157 #include "proto-mdb.h"
159 #endif /* _BACK_MDB_H_ */