ldb_tdb: Provide struct ltdb_private to index routines
[Samba.git] / lib / ldb / ldb_tdb / ldb_tdb.h
blob7871cbcb6d694fbf603232a650441d24f020009d
1 #include "replace.h"
2 #include "system/filesys.h"
3 #include "system/time.h"
4 #include "tdb.h"
5 #include "ldb_module.h"
7 /* this private structure is used by the ltdb backend in the
8 ldb_context */
9 struct ltdb_private {
10 TDB_CONTEXT *tdb;
11 unsigned int connect_flags;
13 unsigned long long sequence_number;
15 /* the low level tdb seqnum - used to avoid loading BASEINFO when
16 possible */
17 int tdb_seqnum;
19 struct ltdb_cache {
20 struct ldb_message *indexlist;
21 bool one_level_indexes;
22 bool attribute_indexes;
23 } *cache;
25 int in_transaction;
27 bool check_base;
28 bool disallow_dn_filter;
29 struct ltdb_idxptr *idxptr;
30 bool prepared_commit;
31 int read_lock_count;
33 bool warn_unindexed;
34 bool warn_reindex;
37 struct ltdb_context {
38 struct ldb_module *module;
39 struct ldb_request *req;
41 bool request_terminated;
42 struct ltdb_req_spy *spy;
44 /* search stuff */
45 const struct ldb_parse_tree *tree;
46 struct ldb_dn *base;
47 enum ldb_scope scope;
48 const char * const *attrs;
49 struct tevent_timer *timeout_event;
51 /* error handling */
52 int error;
55 /* special record types */
56 #define LTDB_INDEX "@INDEX"
57 #define LTDB_INDEXLIST "@INDEXLIST"
58 #define LTDB_IDX "@IDX"
59 #define LTDB_IDXVERSION "@IDXVERSION"
60 #define LTDB_IDXATTR "@IDXATTR"
61 #define LTDB_IDXONE "@IDXONE"
62 #define LTDB_BASEINFO "@BASEINFO"
63 #define LTDB_OPTIONS "@OPTIONS"
64 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
66 /* special attribute types */
67 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
68 #define LTDB_CHECK_BASE "checkBaseOnSearch"
69 #define LTDB_DISALLOW_DN_FILTER "disallowDNFilter"
70 #define LTDB_MOD_TIMESTAMP "whenChanged"
71 #define LTDB_OBJECTCLASS "objectClass"
73 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
75 int ltdb_cache_reload(struct ldb_module *module);
76 int ltdb_cache_load(struct ldb_module *module);
77 int ltdb_increase_sequence_number(struct ldb_module *module);
78 int ltdb_check_at_attributes_values(const struct ldb_val *value);
80 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
82 struct ldb_parse_tree;
84 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
85 int ltdb_index_add_new(struct ldb_module *module,
86 struct ltdb_private *ltdb,
87 const struct ldb_message *msg);
88 int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
89 int ltdb_index_del_element(struct ldb_module *module,
90 struct ltdb_private *ltdb,
91 struct ldb_dn *dn,
92 struct ldb_message_element *el);
93 int ltdb_index_add_element(struct ldb_module *module,
94 struct ltdb_private *ltdb,
95 struct ldb_dn *dn,
96 struct ldb_message_element *el);
97 int ltdb_index_del_value(struct ldb_module *module,
98 struct ltdb_private *ltdb,
99 struct ldb_dn *dn,
100 struct ldb_message_element *el, unsigned int v_idx);
101 int ltdb_reindex(struct ldb_module *module);
102 int ltdb_index_transaction_start(struct ldb_module *module);
103 int ltdb_index_transaction_commit(struct ldb_module *module);
104 int ltdb_index_transaction_cancel(struct ldb_module *module);
106 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
108 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
109 const struct ldb_val *val);
110 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
111 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
112 unsigned int unpack_flags);
113 int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
114 const struct ldb_message *msg, const char * const *attrs,
115 struct ldb_message **filtered_msg);
116 int ltdb_search(struct ltdb_context *ctx);
118 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
119 int ltdb_lock_read(struct ldb_module *module);
120 int ltdb_unlock_read(struct ldb_module *module);
122 * Determine if this key could hold a record. We allow the new GUID
123 * index, the old DN index and a possible future ID=
125 bool ltdb_key_is_record(TDB_DATA key);
126 TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
127 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
128 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
129 int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);
130 int ltdb_err_map(enum TDB_ERROR tdb_code);
132 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
133 const char *path, int hash_size, int tdb_flags,
134 int open_flags, mode_t mode,
135 struct ldb_context *ldb);