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
100 #define mi_id2entry mi_databases[MDB_ID2ENTRY]
101 #define mi_dn2id mi_databases[MDB_DN2ID]
102 #define mi_ad2id mi_databases[MDB_AD2ID]
111 #define MOI_DONTFREE 1
113 /* Copy an ID "src" to pointer "dst" in big-endian byte order */
114 #define MDB_ID2DISK( src, dst ) \
115 do { int i0; ID tmp; unsigned char *_p; \
116 tmp = (src); _p = (unsigned char *)(dst); \
117 for ( i0=sizeof(ID)-1; i0>=0; i0-- ) { \
118 _p[i0] = tmp & 0xff; tmp >>= 8; \
122 /* Copy a pointer "src" to a pointer "dst" from big-endian to native order */
123 #define MDB_DISK2ID( src, dst ) \
124 do { unsigned i0; ID tmp = 0; unsigned char *_p; \
125 _p = (unsigned char *)(src); \
126 for ( i0=0; i0<sizeof(ID); i0++ ) { \
127 tmp <<= 8; tmp |= *_p++; \
133 /* for the cache of attribute information (which are indexed, etc.) */
134 typedef struct mdb_attrinfo {
135 AttributeDescription *ai_desc; /* attribute description cn;lang-en */
136 slap_mask_t ai_indexmask; /* how the attr is indexed */
137 slap_mask_t ai_newmask; /* new settings to replace old mask */
138 #ifdef LDAP_COMP_MATCH
139 ComponentReference* ai_cr; /*component indexing*/
141 int ai_idx; /* position in AI array */
144 /* These flags must not clash with SLAP_INDEX flags or ops in slap.h! */
145 #define MDB_INDEX_DELETING 0x8000U /* index is being modified */
146 #define MDB_INDEX_UPDATE_OP 0x03 /* performing an index update */
148 /* For slapindex to record which attrs in an entry belong to which
151 typedef struct AttrList {
152 struct AttrList *next;
156 typedef struct IndexRec {
161 #include "proto-mdb.h"
163 #endif /* _BACK_MDB_H_ */