1 /* back-bdb2.h - ldap bdb2 back-end header file */
11 #define DEFAULT_CACHE_SIZE 1000
13 /* since DEFAULT_DB_PAGE_SIZE is 1K, we have 128K,
14 which is suggested by Sleepycat */
15 #define DEFAULT_DBCACHE_SIZE (128 * DEFAULT_DB_PAGE_SIZE)
17 #define DEFAULT_DB_DIRECTORY "/usr/tmp"
18 #define DEFAULT_DB_HOME "/usr/tmp"
19 #define DEFAULT_MODE 0600
23 #define BDB2_SUFFIX ".bdb2"
27 * there is a single index for each attribute. these prefixes insure
28 * that there is no collision among keys.
30 #define EQ_PREFIX '=' /* prefix for equality keys */
31 #define APPROX_PREFIX '~' /* prefix for approx keys */
32 #define SUB_PREFIX '*' /* prefix for substring keys */
33 #define CONT_PREFIX '\\' /* prefix for continuation keys */
35 #define UNKNOWN_PREFIX '?' /* prefix for unknown keys */
37 #define DEFAULT_BLOCKSIZE 8192
40 * This structure represents an id block on disk and an id list
43 * The fields have the following meanings:
45 * b_nmax maximum number of ids in this block. if this is == ALLIDSBLOCK,
46 * then this block represents all ids.
47 * b_nids current number of ids in use in this block. if this
48 * is == INDBLOCK, then this block is an indirect block
49 * containing a list of other blocks containing actual ids.
50 * the list is terminated by an id of NOID.
51 * b_ids a list of the actual ids themselves
56 #define ID_BLOCK_NMAX_OFFSET 0
57 #define ID_BLOCK_NIDS_OFFSET 1
58 #define ID_BLOCK_IDS_OFFSET 2
60 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
62 #define ID_BLOCK_NMAX(b) ((b)[ID_BLOCK_NMAX_OFFSET])
63 #define ID_BLOCK_NIDS(b) ((b)[ID_BLOCK_NIDS_OFFSET])
64 #define ID_BLOCK_ID(b, n) ((b)[ID_BLOCK_IDS_OFFSET+(n)])
66 #define ID_BLOCK_NOID(b, n) (ID_BLOCK_ID((b),(n)) == NOID)
68 #define ID_BLOCK_ALLIDS_VALUE 0
69 #define ID_BLOCK_ALLIDS(b) (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
71 #define ID_BLOCK_INDIRECT_VALUE 0
72 #define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
74 /* for the in-core cache of entries */
80 Entry *c_lruhead; /* lru - add accessed entries here */
81 Entry *c_lrutail; /* lru - rem lru entries from here */
82 ldap_pvt_thread_mutex_t c_mutex;
85 #define CACHE_READ_LOCK 1
86 #define CACHE_WRITE_LOCK 2
88 /* for the cache of open index files (re-used for txn) */
100 typedef struct dbcache BDB2_TXN_FILES;
103 /* for the cache of attribute information (which are indexed, etc.) */
105 char *ai_type; /* type name (cn, sn, ...) */
106 int ai_indexmask; /* how the attr is indexed */
107 #define INDEX_PRESENCE 0x01
108 #define INDEX_EQUALITY 0x02
109 #define INDEX_APPROX 0x04
110 #define INDEX_SUB 0x08
111 #define INDEX_UNKNOWN 0x10
112 #define INDEX_FROMINIT 0x20
113 int ai_syntaxmask; /* what kind of syntax */
115 #define SYNTAX_CIS 0x01
116 #define SYNTAX_CES 0x02
117 #define SYNTAX_BIN 0x04
122 #define MAXDBCACHE 10
124 /* this could be made an option */
125 #ifndef SLAPD_NEXTID_CHUNK
126 #define SLAPD_NEXTID_CHUNK 32
132 typedef struct _bdb2_txn_head {
134 /* log size and timer to control checkpoints */
138 /* a list of all DB files in use */
139 BDB2_TXN_FILES *dbFiles;
141 /* we have five fixed files */
142 #define BDB2_DB_DN_FILE 0
143 #define BDB2_DB_DN2ID_FILE 1
144 #define BDB2_DB_ID2ENTRY_FILE 2
145 #define BDB2_DB_ID2CHILDREN_FILE 3
146 #define BDB2_DB_OC_IDX_FILE 4
148 /* a database handle for the NEXTID file
149 (must be opened like all DB files at startup
150 and closed on shutdown */
153 /* is the default attribute index set to non-none */
155 #define BDB2_WITH_DEF_IDX 1
157 /* a handle for the backend's environment */
163 /* end of TP stuff */
166 /* the private description of a backend type */
173 #define with_timing(bi) (((struct ldbtype *) \
174 (bi)->bi_private)->lty_betiming == 1)
176 /* The DB environment */
177 extern DB_ENV bdb2i_dbEnv;
180 /* the private description of a database */
183 #if SLAPD_NEXTID_CHUNK > 1
186 char *li_nextid_file;
189 struct cache li_cache;
194 /* a list of all files of the database */
195 BDB2_TXN_HEAD li_txn_head;
200 #include "proto-back-bdb2.h"
204 #endif /* _back_bdb2_h_ */