s4:ldb Remove obsolete comment about ldb_tdb's sequence num
[metze/samba/wip.git] / source4 / lib / ldb / ldb_tdb / ldb_tdb.h
index c20c3bd5f9c4473a7b9015b2bfb15fa599ed7774..75034dcf4b333ad76360d64a482689b5f86c311a 100644 (file)
@@ -1,15 +1,6 @@
-
-#ifdef _SAMBA_BUILD_
-#include "system/filesys.h"
-#endif
-
-#if (_SAMBA_BUILD_ >= 4)
-#include "lib/tdb/include/tdb.h"
-#elif defined(_SAMBA_BUILD_)
-#include "tdb/include/tdb.h"
-#else
+#include "ldb_includes.h"
 #include "tdb.h"
-#endif
+#include "ldb_module.h"
 
 /* this private structure is used by the ltdb backend in the
    ldb_context */
@@ -17,51 +8,66 @@ struct ltdb_private {
        TDB_CONTEXT *tdb;
        unsigned int connect_flags;
        
-       /* a double is used for portability and ease of string
-          handling. It has plenty of digits of precision */
        unsigned long long sequence_number;
 
+       /* the low level tdb seqnum - used to avoid loading BASEINFO when
+          possible */
+       int tdb_seqnum;
+
        struct ltdb_cache {
                struct ldb_message *indexlist;
                struct ldb_message *attributes;
-               struct ldb_message *subclasses;
 
                struct {
                        char *name;
                        int flags;
                } last_attribute;
        } *cache;
+
+       int in_transaction;
+
+       bool check_base;
+       struct ltdb_idxptr *idxptr;
+       bool prepared_commit;
 };
 
 /*
   the async local context
   holds also internal search state during a full db search
 */
+struct ltdb_req_spy {
+       struct ltdb_context *ctx;
+};
+
 struct ltdb_context {
        struct ldb_module *module;
+       struct ldb_request *req;
+
+       bool request_terminated;
+       struct ltdb_req_spy *spy;
 
        /* search stuff */
        const struct ldb_parse_tree *tree;
-       const struct ldb_dn *base;
+       struct ldb_dn *base;
        enum ldb_scope scope;
        const char * const *attrs;
-
-       /* async stuff */
-       void *context;
-       int (*callback)(struct ldb_context *, void *, struct ldb_reply *);
+       struct tevent_timer *timeout_event;
 };
 
 /* special record types */
 #define LTDB_INDEX      "@INDEX"
 #define LTDB_INDEXLIST  "@INDEXLIST"
 #define LTDB_IDX        "@IDX"
+#define LTDB_IDXPTR     "@IDXPTR"
 #define LTDB_IDXATTR    "@IDXATTR"
+#define LTDB_IDXONE     "@IDXONE"
 #define LTDB_BASEINFO   "@BASEINFO"
+#define LTDB_OPTIONS    "@OPTIONS"
 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
-#define LTDB_SUBCLASSES "@SUBCLASSES"
 
 /* special attribute types */
 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
+#define LTDB_CHECK_BASE "checkBaseOnSearch"
 #define LTDB_MOD_TIMESTAMP "whenChanged"
 #define LTDB_OBJECTCLASS "objectClass"
 
@@ -76,10 +82,14 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value);
 
 struct ldb_parse_tree;
 
-int ltdb_search_indexed(struct ldb_handle *handle);
+int ltdb_search_indexed(struct ltdb_context *ctx);
 int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg);
 int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg);
+int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add);
 int ltdb_reindex(struct ldb_module *module);
+int ltdb_index_transaction_start(struct ldb_module *module);
+int ltdb_index_transaction_commit(struct ldb_module *module);
+int ltdb_index_transaction_cancel(struct ldb_module *module);
 
 /* The following definitions come from lib/ldb/ldb_tdb/ldb_pack.c  */
 
@@ -97,7 +107,7 @@ int ltdb_unpack_data(struct ldb_module *module,
 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, 
                      const struct ldb_val *val);
 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
-int ltdb_search_dn1(struct ldb_module *module, const struct ldb_dn *dn, struct ldb_message *msg);
+int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg);
 int ltdb_add_attr_results(struct ldb_module *module,
                          TALLOC_CTX *mem_ctx, 
                          struct ldb_message *msg,
@@ -105,14 +115,14 @@ int ltdb_add_attr_results(struct ldb_module *module,
                          unsigned int *count, 
                          struct ldb_message ***res);
 int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs);
-int ltdb_search(struct ldb_module *module, struct ldb_request *req);
+int ltdb_search(struct ltdb_context *ctx);
 
 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
-struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
-                                   struct ldb_request *req);
-struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn);
+int ltdb_lock_read(struct ldb_module *module);
+int ltdb_unlock_read(struct ldb_module *module);
+struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
-int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn);
+int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);
 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg);
 
 int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
@@ -122,4 +132,3 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
                                   const char *path, int hash_size, int tdb_flags,
                                   int open_flags, mode_t mode,
                                   struct ldb_context *ldb);
-