ldb: make key/value backends expose if there is an active transaction
[samba.git] / lib / ldb / ldb_tdb / ldb_tdb.h
index 60ba2652a61d702d996d70f531083e7cb9f1eb8f..72ebb9713f2f70ebbb20201fe4a79b2ed1107afa 100644 (file)
@@ -5,13 +5,31 @@
 #include "ldb_module.h"
 
 struct ltdb_private;
+typedef int (*ldb_kv_traverse_fn)(struct ltdb_private *ltdb,
+                                 struct ldb_val key, struct ldb_val data,
+                                 void *ctx);
+
 struct kv_db_ops {
-       int (*store)(struct ltdb_private *ltdb, TDB_DATA key, TDB_DATA data, int flags);
-       int (*delete)(struct ltdb_private *ltdb, TDB_DATA key);
+       int (*store)(struct ltdb_private *ltdb, struct ldb_val key, struct ldb_val data, int flags);
+       int (*delete)(struct ltdb_private *ltdb, struct ldb_val key);
+       int (*iterate)(struct ltdb_private *ltdb, ldb_kv_traverse_fn fn, void *ctx);
+       int (*update_in_iterate)(struct ltdb_private *ltdb, struct ldb_val key,
+                                struct ldb_val key2, struct ldb_val data, void *ctx);
+       int (*fetch_and_parse)(struct ltdb_private *ltdb, struct ldb_val key,
+                               int (*parser)(struct ldb_val key, struct ldb_val data,
+                                             void *private_data),
+                               void *ctx);
        int (*lock_read)(struct ldb_module *);
        int (*unlock_read)(struct ldb_module *);
+       int (*begin_write)(struct ltdb_private *);
+       int (*prepare_write)(struct ltdb_private *);
+       int (*abort_write)(struct ltdb_private *);
+       int (*finish_write)(struct ltdb_private *);
        int (*error)(struct ltdb_private *ltdb);
+       const char * (*errorstr)(struct ltdb_private *ltdb);
        const char * (*name)(struct ltdb_private *ltdb);
+       bool (*has_changed)(struct ltdb_private *ltdb);
+       bool (*transaction_active)(struct ltdb_private *ltdb);
 };
 
 /* this private structure is used by the ltdb backend in the
@@ -48,6 +66,8 @@ struct ltdb_private {
 
        bool read_only;
 
+       bool reindex_failed;
+
        const struct ldb_schema_syntax *GUID_index_syntax;
 
        /*
@@ -76,6 +96,13 @@ struct ltdb_context {
        int error;
 };
 
+struct ltdb_reindex_context {
+       struct ldb_module *module;
+       int error;
+       uint32_t count;
+};
+
+
 /* special record types */
 #define LTDB_INDEX      "@INDEX"
 #define LTDB_INDEXLIST  "@INDEXLIST"
@@ -161,8 +188,6 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
 int ltdb_search(struct ltdb_context *ctx);
 
 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
-int ltdb_lock_read(struct ldb_module *module);
-int ltdb_unlock_read(struct ldb_module *module);
 /* 
  * Determine if this key could hold a record.  We allow the new GUID
  * index, the old DN index and a possible future ID=
@@ -181,6 +206,7 @@ int ltdb_idx_to_key(struct ldb_module *module,
                    TALLOC_CTX *mem_ctx,
                    const struct ldb_val *idx_val,
                    TDB_DATA *key);
+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_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
 int ltdb_delete_noindex(struct ldb_module *module,
@@ -191,3 +217,10 @@ 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);
+int init_store(struct ltdb_private *ltdb, const char *name,
+              struct ldb_context *ldb, const char *options[],
+              struct ldb_module **_module);
+
+int ltdb_connect(struct ldb_context *ldb, const char *url,
+                unsigned int flags, const char *options[],
+                struct ldb_module **_module);