1 /* back-bdb2.h - ldap bdb2 back-end header file */
12 #define DEFAULT_CACHE_SIZE 1000
14 /* since DEFAULT_DB_PAGE_SIZE is 1K, we have 128K,
15 which is suggested by Sleepycat */
16 #define DEFAULT_DBCACHE_SIZE (128 * DEFAULT_DB_PAGE_SIZE)
18 #define DEFAULT_DB_DIRECTORY LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb2"
19 #define DEFAULT_DB_HOME DEFAULT_DB_DIRECTORY
20 #define DEFAULT_MODE 0600
24 #define DN_BASE_PREFIX '='
25 #define DN_ONE_PREFIX '@'
26 #define DN_SUBTREE_PREFIX '?'
28 #define BDB2_SUFFIX ".bdb2"
32 * there is a single index for each attribute. these prefixes ensure
33 * that there is no collision among keys.
35 #define EQ_PREFIX '=' /* prefix for equality keys */
36 #define APPROX_PREFIX '~' /* prefix for approx keys */
37 #define SUB_PREFIX '*' /* prefix for substring keys */
38 #define CONT_PREFIX '\\' /* prefix for continuation keys */
40 /* allow 3 characters per byte + PREFIX + EOS */
41 #define CONT_SIZE ( sizeof(long)*3 + 1 + 1 )
44 #define UNKNOWN_PREFIX '?' /* prefix for unknown keys */
46 #define DEFAULT_BLOCKSIZE 8192
49 * This structure represents an id block on disk and an id list
52 * The fields have the following meanings:
54 * b_nmax maximum number of ids in this block. if this is == ALLIDSBLOCK,
55 * then this block represents all ids.
56 * b_nids current number of ids in use in this block. if this
57 * is == INDBLOCK, then this block is an indirect block
58 * containing a list of other blocks containing actual ids.
59 * the list is terminated by an id of NOID.
60 * b_ids a list of the actual ids themselves
65 #define ID_BLOCK_NMAX_OFFSET 0
66 #define ID_BLOCK_NIDS_OFFSET 1
67 #define ID_BLOCK_IDS_OFFSET 2
69 /* all ID_BLOCK macros operate on a pointer to a ID_BLOCK */
71 #define ID_BLOCK_NMAX(b) ((b)[ID_BLOCK_NMAX_OFFSET])
72 #define ID_BLOCK_NIDS(b) ((b)[ID_BLOCK_NIDS_OFFSET])
73 #define ID_BLOCK_ID(b, n) ((b)[ID_BLOCK_IDS_OFFSET+(n)])
75 #define ID_BLOCK_NOID(b, n) (ID_BLOCK_ID((b),(n)) == NOID)
77 #define ID_BLOCK_ALLIDS_VALUE 0
78 #define ID_BLOCK_ALLIDS(b) (ID_BLOCK_NMAX(b) == ID_BLOCK_ALLIDS_VALUE)
80 #define ID_BLOCK_INDIRECT_VALUE 0
81 #define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
83 /* for the in-core cache of entries */
89 Entry *c_lruhead; /* lru - add accessed entries here */
90 Entry *c_lrutail; /* lru - rem lru entries from here */
91 ldap_pvt_thread_mutex_t c_mutex;
94 #define CACHE_READ_LOCK 0
95 #define CACHE_WRITE_LOCK 1
97 /* for the cache of open index files (re-used for txn) */
106 struct dbcache *next;
109 typedef struct dbcache BDB2_TXN_FILES;
110 typedef struct dbcache DBCache;
113 /* for the cache of attribute information (which are indexed, etc.) */
115 char *ai_type; /* type name (cn, sn, ...) */
116 int ai_indexmask; /* how the attr is indexed */
117 #define INDEX_PRESENCE 0x0001
118 #define INDEX_EQUALITY 0x0002
119 #define INDEX_APPROX 0x0004
120 #define INDEX_SUB 0x0008
121 #define INDEX_UNKNOWN 0x0010
122 #define INDEX_FROMINIT 0x1000
123 int ai_syntaxmask; /* what kind of syntax */
125 #define SYNTAX_CIS 0x01
126 #define SYNTAX_CES 0x02
127 #define SYNTAX_BIN 0x04
134 typedef struct _bdb2_txn_head {
136 /* log size and timer to control checkpoints */
140 /* a list of all DB files in use */
141 BDB2_TXN_FILES *dbFiles;
143 /* we have five fixed files */
144 #define BDB2_DB_DN_FILE 0
145 #define BDB2_DB_DN2ID_FILE 1
146 #define BDB2_DB_ID2ENTRY_FILE 2
147 #define BDB2_DB_ID2CHILDREN_FILE 3
148 #define BDB2_DB_OC_IDX_FILE 4
150 /* a database handle for the NEXTID file
151 (must be opened like all DB files at startup
152 and closed on shutdown */
155 /* is the default attribute index set to non-none */
157 #define BDB2_WITH_DEF_IDX 1
159 /* a handle for the backend's environment */
165 /* end of TP stuff */
168 /* the private description of a backend type */
175 #define with_timing(bi) (((struct ldbtype *) \
176 (bi)->bi_private)->lty_betiming == 1)
178 /* The DB environment */
179 extern DB_ENV bdb2i_dbEnv;
182 /* the private description of a database */
185 char *li_nextid_file;
188 struct cache li_cache;
192 /* a list of all files of the database */
193 BDB2_TXN_HEAD li_txn_head;
197 #include "proto-back-bdb2.h"
201 #endif /* _back_bdb2_h_ */