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
44 struct berval mdi_name;
49 #define MDB_MONITOR_IDX
50 #endif /* LDAP_DEVEL */
52 typedef struct mdb_monitor_t {
54 struct berval mdm_ndn;
63 /* DB_ENV parameters */
64 /* The DB_ENV can be tuned via DB_CONFIG */
66 u_int32_t mi_dbenv_flags;
72 int mi_db_opflags; /* db-specific flags */
73 struct mdb_db_info **mi_databases;
74 ldap_pvt_thread_mutex_t mi_database_mutex;
76 slap_mask_t mi_defaultmask;
77 struct mdb_attrinfo **mi_attrs;
79 void *mi_search_stack;
80 int mi_search_stack_depth;
83 u_int32_t mi_txn_cp_min;
84 u_int32_t mi_txn_cp_kbyte;
85 struct re_s *mi_txn_cp_task;
86 struct re_s *mi_index_task;
88 mdb_monitor_t mi_monitor;
90 #ifdef MDB_MONITOR_IDX
91 ldap_pvt_thread_mutex_t mi_idx_mutex;
93 #endif /* MDB_MONITOR_IDX */
96 #define MDB_IS_OPEN 0x01
97 #define MDB_DEL_INDEX 0x08
98 #define MDB_RE_OPEN 0x10
101 #define mi_id2entry mi_databases[MDB_ID2ENTRY]
102 #define mi_dn2id mi_databases[MDB_DN2ID]
103 #define mi_ad2id mi_databases[MDB_AD2ID]
112 #define MOI_DONTFREE 1
114 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
115 #define MDB_ID2DISK( src, dst ) \
116 do { int i0; ID tmp; unsigned char *_p; \
117 tmp = (src); _p = (unsigned char *)(dst); \
118 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
119 _p[i0] = tmp & 0xff; tmp >>= 8; \
123 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
124 #define MDB_DISK2ID( src, dst ) \
125 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
126 _p = (unsigned char *)(src); \
127 for ( i0=0; i0<sizeof(ID); i0++ ) { \
128 tmp <<= 8; tmp |= *_p++; \
134 /* for the cache of attribute information (which are indexed, etc.) */
135 typedef struct mdb_attrinfo {
136 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
137 slap_mask_t ai_indexmask; /* how the attr is indexed */
138 slap_mask_t ai_newmask; /* new settings to replace old mask */
139 #ifdef LDAP_COMP_MATCH
140 ComponentReference* ai_cr; /*component indexing*/
142 int ai_idx; /* position in AI array */
145 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
146 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
147 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
149 /* For slapindex to record which attrs in an entry belong to which
152 typedef struct AttrList {
153 struct AttrList *next;
157 typedef struct IndexRec {
162 #include "proto-mdb.h"
164 #endif /* _BACK_MDB_H_ */