s4-ldb: merged with master
[Samba/ekacnet.git] / source4 / lib / ldb / ldb_tdb / ldb_tdb.h
blob43f2909008afeba418d5c21a74a0047c6c118bcf
1 #include "ldb_includes.h"
2 #include "tdb.h"
3 #include "ldb_module.h"
5 /* this private structure is used by the ltdb backend in the
6 ldb_context */
7 struct ltdb_private {
8 TDB_CONTEXT *tdb;
9 unsigned int connect_flags;
11 unsigned long long sequence_number;
13 /* the low level tdb seqnum - used to avoid loading BASEINFO when
14 possible */
15 int tdb_seqnum;
17 struct ltdb_cache {
18 struct ldb_message *indexlist;
19 struct ldb_message *attributes;
21 struct {
22 char *name;
23 int flags;
24 } last_attribute;
25 } *cache;
27 int in_transaction;
29 bool check_base;
30 struct ltdb_idxptr *idxptr;
31 bool prepared_commit;
33 int index_version;
37 the async local context
38 holds also internal search state during a full db search
40 struct ltdb_req_spy {
41 struct ltdb_context *ctx;
44 struct ltdb_context {
45 struct ldb_module *module;
46 struct ldb_request *req;
48 bool request_terminated;
49 struct ltdb_req_spy *spy;
51 /* search stuff */
52 const struct ldb_parse_tree *tree;
53 struct ldb_dn *base;
54 enum ldb_scope scope;
55 const char * const *attrs;
56 struct tevent_timer *timeout_event;
59 /* special record types */
60 #define LTDB_INDEX "@INDEX"
61 #define LTDB_INDEXLIST "@INDEXLIST"
62 #define LTDB_IDX "@IDX"
63 #define LTDB_IDXPTR "@IDXPTR"
64 #define LTDB_IDXATTR "@IDXATTR"
65 #define LTDB_IDXONE "@IDXONE"
66 #define LTDB_BASEINFO "@BASEINFO"
67 #define LTDB_OPTIONS "@OPTIONS"
68 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
70 #define LTDB_INDEX_VERSION "@INDEX_VERSION"
72 /* ltdb index versions:
73 0 - Initial version, DN values as index values, not casefolded
74 1 - DN values as index values, casefolded and sorted (binary compare)
78 /* special attribute types */
79 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
80 #define LTDB_CHECK_BASE "checkBaseOnSearch"
81 #define LTDB_MOD_TIMESTAMP "whenChanged"
82 #define LTDB_OBJECTCLASS "objectClass"
84 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
86 int ltdb_cache_reload(struct ldb_module *module);
87 int ltdb_cache_load(struct ldb_module *module);
88 int ltdb_increase_sequence_number(struct ldb_module *module);
89 int ltdb_set_casefold_index(struct ldb_module *module);
90 int ltdb_check_at_attributes_values(const struct ldb_val *value);
92 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
94 struct ldb_parse_tree;
96 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
97 int ltdb_index_add(struct ldb_module *module, TALLOC_CTX *mem_ctx,
98 const struct ldb_message *msg);
99 int ltdb_index_del(struct ldb_module *module, TALLOC_CTX *mem_ctx,
100 const struct ldb_message *msg);
101 int ltdb_index_one(struct ldb_module *module, TALLOC_CTX *mem_ctx,
102 const struct ldb_message *msg, int add);
103 int ltdb_reindex(struct ldb_module *module);
104 int ltdb_index_transaction_start(struct ldb_module *module);
105 int ltdb_index_transaction_prepare_commit(struct ldb_module *module);
106 int ltdb_index_transaction_cancel(struct ldb_module *module);
108 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c */
110 int ltdb_pack_data(struct ldb_module *module,
111 const struct ldb_message *message,
112 struct TDB_DATA *data);
113 void ltdb_unpack_data_free(struct ldb_module *module,
114 struct ldb_message *message);
115 int ltdb_unpack_data(struct ldb_module *module,
116 const struct TDB_DATA *data,
117 struct ldb_message *message);
119 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
121 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
122 const struct ldb_val *val);
123 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
125 search the database for a single tdb key, returning all attributes
126 in a single message
128 return LDB_ERR_NO_SUCH_OBJECT on record-not-found
129 and LDB_SUCCESS on success
131 int ltdb_search_dn1_key(struct ldb_module *module, TDB_DATA tdb_key, struct ldb_message *msg);
132 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg);
133 int ltdb_add_attr_results(struct ldb_module *module,
134 TALLOC_CTX *mem_ctx,
135 struct ldb_message *msg,
136 const char * const attrs[],
137 unsigned int *count,
138 struct ldb_message ***res);
139 int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs);
140 int ltdb_search(struct ltdb_context *ctx);
142 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
143 int ltdb_lock_read(struct ldb_module *module);
144 int ltdb_unlock_read(struct ldb_module *module);
145 struct TDB_DATA ltdb_key(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
147 form a TDB_DATA for a record key
148 caller frees
150 This version takes the casefolded string form of the DN as an ldb_val
152 struct TDB_DATA ltdb_key_from_casefold_dn(TALLOC_CTX *mem_ctx,
153 struct ldb_val dn_folded);
154 struct ldb_val ldb_dn_get_casefold_as_ldb_val(struct ldb_dn *dn);
155 struct ldb_val ldb_dn_alloc_casefold_as_ldb_val(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
156 int ltdb_store(struct ldb_module *module, TALLOC_CTX *mem_ctx,
157 const struct ldb_message *msg, int flgs);
158 int ltdb_delete_noindex(struct ldb_module *module, TALLOC_CTX *mem_ctx,
159 struct ldb_dn *dn);
160 int ltdb_modify_internal(struct ldb_module *module, TALLOC_CTX *mem_ctx,
161 const struct ldb_message *msg);
163 int ltdb_index_del_value(struct ldb_module *module, TALLOC_CTX *mem_ctx,
164 struct ldb_dn *dn,
165 struct ldb_message_element *el, int v_idx);
167 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
168 const char *path, int hash_size, int tdb_flags,
169 int open_flags, mode_t mode,
170 struct ldb_context *ldb);