ldb_tdb: Disallow TDB nested transactions and use tdb_transaction_active()
[samba.git] / lib / ldb / ldb_tdb / ldb_tdb.h
index 4d4805b98efb1818d1a457963211ca4fbf9114f2..4d531208da6f00d9ee7909bf4018ea7c287dd571 100644 (file)
@@ -5,9 +5,20 @@
 #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 *);
@@ -15,7 +26,10 @@ struct kv_db_ops {
        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
@@ -39,7 +53,6 @@ struct ltdb_private {
                const char *GUID_index_dn_component;
        } *cache;
 
-       int in_transaction;
 
        bool check_base;
        bool disallow_dn_filter;
@@ -52,6 +65,8 @@ struct ltdb_private {
 
        bool read_only;
 
+       bool reindex_failed;
+
        const struct ldb_schema_syntax *GUID_index_syntax;
 
        /*
@@ -80,6 +95,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"
@@ -194,3 +216,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);