r10299: remove the public (un)lock functions and introduce a transaction based
authorSimo Sorce <idra@samba.org>
Sat, 17 Sep 2005 19:25:50 +0000 (19:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:38:14 +0000 (13:38 -0500)
private ldb API

ldb_sqlite3 is already working with this model and ldb_tdb will do
as soon as tridge finishes the tdb transaction code.

currently the transactions are always implicit and wrap any single
ldb API call except searching, the transaction functions are
currently not made public on purpose.

Simo.

13 files changed:
source/lib/ldb/common/ldb.c
source/lib/ldb/common/ldb_modules.c
source/lib/ldb/include/ldb_private.h
source/lib/ldb/ldb_ildap/ldb_ildap.c
source/lib/ldb/ldb_ldap/ldb_ldap.c
source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
source/lib/ldb/ldb_tdb/ldb_tdb.c
source/lib/ldb/modules/ldb_map.c
source/lib/ldb/modules/rdn_name.c
source/lib/ldb/modules/schema.c
source/lib/ldb/modules/skel.c
source/lib/ldb/modules/timestamps.c
source/lib/ldb/tools/ldbtest.c

index 25e7bee66b749a4135037d571a012b1e87d5e6e7..ae71f087131e832adbc089a4b16ba79fb8b057e7 100644 (file)
@@ -105,6 +105,22 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
        return 0;
 }
 
+/*
+  start a transaction
+*/
+static int ldb_start_trans(struct ldb_context *ldb)
+{
+        return ldb->modules->ops->start_transaction(ldb->modules);
+}
+
+/*
+  end a transaction
+*/
+static int ldb_end_trans(struct ldb_context *ldb, int status)
+{
+        return ldb->modules->ops->end_transaction(ldb->modules, status);
+}
+
 /*
   search the database given a LDAP-like search expression
 
@@ -146,7 +162,11 @@ int ldb_search_bytree(struct ldb_context *ldb,
 int ldb_add(struct ldb_context *ldb, 
            const struct ldb_message *message)
 {
-       return ldb->modules->ops->add_record(ldb->modules, message);
+       int status = ldb_start_trans(ldb);
+       if (status != 0) return status;
+
+       status = ldb->modules->ops->add_record(ldb->modules, message);
+       return ldb_end_trans(ldb, status);
 }
 
 /*
@@ -155,7 +175,11 @@ int ldb_add(struct ldb_context *ldb,
 int ldb_modify(struct ldb_context *ldb, 
               const struct ldb_message *message)
 {
-       return ldb->modules->ops->modify_record(ldb->modules, message);
+       int status = ldb_start_trans(ldb);
+       if (status != 0) return status;
+
+       status = ldb->modules->ops->modify_record(ldb->modules, message);
+       return ldb_end_trans(ldb, status);
 }
 
 
@@ -164,7 +188,11 @@ int ldb_modify(struct ldb_context *ldb,
 */
 int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
 {
-       return ldb->modules->ops->delete_record(ldb->modules, dn);
+       int status = ldb_start_trans(ldb);
+       if (status != 0) return status;
+
+       status = ldb->modules->ops->delete_record(ldb->modules, dn);
+       return ldb_end_trans(ldb, status);
 }
 
 /*
@@ -172,23 +200,11 @@ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
 */
 int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
 {
-       return ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
-}
+       int status = ldb_start_trans(ldb);
+       if (status != 0) return status;
 
-/*
-  create a named lock
-*/
-int ldb_lock(struct ldb_context *ldb, const char *lockname)
-{
-        return ldb->modules->ops->named_lock(ldb->modules, lockname);
-}
-
-/*
-  release a named lock
-*/
-int ldb_unlock(struct ldb_context *ldb, const char *lockname)
-{
-        return ldb->modules->ops->named_unlock(ldb->modules, lockname);
+       status = ldb->modules->ops->rename_record(ldb->modules, olddn, newdn);
+       return ldb_end_trans(ldb, status);
 }
 
 /*
index 20e8ad061ead1065a605fbc0a6edc2df0ec30835..29bc8264e96222dcfc9833f55ef001b892ac96f9 100644 (file)
@@ -306,20 +306,20 @@ int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn
        return module->next->ops->rename_record(module->next, olddn, newdn);
 }
 
-int ldb_next_named_lock(struct ldb_module *module, const char *lockname)
+int ldb_next_start_trans(struct ldb_module *module)
 {
        if (!module->next) {
                return -1;
        }
-       return module->next->ops->named_lock(module->next, lockname);
+       return module->next->ops->start_transaction(module->next);
 }
 
-int ldb_next_named_unlock(struct ldb_module *module, const char *lockname)
+int ldb_next_end_trans(struct ldb_module *module, int status)
 {
        if (!module->next) {
                return -1;
        }
-       return module->next->ops->named_unlock(module->next, lockname);
+       return module->next->ops->end_transaction(module->next, status);
 }
 
 const char *ldb_next_errstring(struct ldb_module *module)
index f5b50f5fc03a432653139b3dc6a62fa759767342..e55a19c28c6754ff2517a6a50ce72f16edd539e4 100644 (file)
@@ -64,8 +64,8 @@ struct ldb_module_ops {
        int (*modify_record)(struct ldb_module *, const struct ldb_message *);
        int (*delete_record)(struct ldb_module *, const struct ldb_dn *);
        int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *);
-       int (*named_lock)(struct ldb_module *, const char *);
-       int (*named_unlock)(struct ldb_module *, const char *);
+       int (*start_transaction)(struct ldb_module *);
+       int (*end_transaction)(struct ldb_module *, int);
        const char * (*errstring)(struct ldb_module *);
 };
 
@@ -135,8 +135,8 @@ int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *mes
 int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
 int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn);
 int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
-int ldb_next_named_lock(struct ldb_module *module, const char *lockname);
-int ldb_next_named_unlock(struct ldb_module *module, const char *lockname);
+int ldb_next_start_trans(struct ldb_module *module);
+int ldb_next_end_trans(struct ldb_module *module, int status);
 const char *ldb_next_errstring(struct ldb_module *module);
 
 /* The following definitions come from lib/ldb/common/ldb_debug.c  */
index 3d47863067179abf858a88373f8a91731c0cdc61..d4239c0f723c4f87f1a05fb05178e3ec1193c113 100644 (file)
@@ -362,30 +362,18 @@ static int ildb_modify(struct ldb_module *module, const struct ldb_message *msg)
        return ret;
 }
 
-static int ildb_lock(struct ldb_module *module, const char *lockname)
+static int ildb_start_trans(struct ldb_module *module)
 {
-       int ret = 0;
-
-       if (lockname == NULL) {
-               return -1;
-       }
-
        /* TODO implement a local locking mechanism here */
 
-       return ret;
+       return 0;
 }
 
-static int ildb_unlock(struct ldb_module *module, const char *lockname)
+static int ildb_end_trans(struct ldb_module *module, int status)
 {
-       int ret = 0;
-
-       if (lockname == NULL) {
-               return -1;
-       }
-
-       /* TODO implement a local unlocking mechanism here */
+       /* TODO implement a local transaction mechanism here */
 
-       return ret;
+       return status;
 }
 
 /*
@@ -403,16 +391,16 @@ static const char *ildb_errstring(struct ldb_module *module)
 
 
 static const struct ldb_module_ops ildb_ops = {
-       .name          = "ldap",
-       .search        = ildb_search,
-       .search_bytree = ildb_search_bytree,
-       .add_record    = ildb_add,
-       .modify_record = ildb_modify,
-       .delete_record = ildb_delete,
-       .rename_record = ildb_rename,
-       .named_lock    = ildb_lock,
-       .named_unlock  = ildb_unlock,
-       .errstring     = ildb_errstring
+       .name              = "ldap",
+       .search            = ildb_search,
+       .search_bytree     = ildb_search_bytree,
+       .add_record        = ildb_add,
+       .modify_record     = ildb_modify,
+       .delete_record     = ildb_delete,
+       .rename_record     = ildb_rename,
+       .start_transaction = ildb_start_trans,
+       .end_transaction   = ildb_end_trans,
+       .errstring         = ildb_errstring
 };
 
 
index 2da4f1af8e07dc1f4fbbe61ff30b10714668c474..39f56dba0e9c7213ba0763037cedf3d08d9345d2 100644 (file)
@@ -450,30 +450,18 @@ static int lldb_modify(struct ldb_module *module, const struct ldb_message *msg)
        return ret;
 }
 
-static int lldb_lock(struct ldb_module *module, const char *lockname)
+static int lldb_start_trans(struct ldb_module *module)
 {
-       int ret = 0;
-
-       if (lockname == NULL) {
-               return -1;
-       }
+       /* TODO implement a local transaction mechanism here */
 
-       /* TODO implement a local locking mechanism here */
-
-       return ret;
+       return 0;
 }
 
-static int lldb_unlock(struct ldb_module *module, const char *lockname)
+static int lldb_end_trans(struct ldb_module *module, int status)
 {
-       int ret = 0;
-
-       if (lockname == NULL) {
-               return -1;
-       }
-
-       /* TODO implement a local unlocking mechanism here */
+       /* TODO implement a local transaction mechanism here */
 
-       return ret;
+       return status;
 }
 
 /*
@@ -487,16 +475,16 @@ static const char *lldb_errstring(struct ldb_module *module)
 
 
 static const struct ldb_module_ops lldb_ops = {
-       .name          = "ldap",
-       .search        = lldb_search,
-       .search_bytree = lldb_search_bytree,
-       .add_record    = lldb_add,
-       .modify_record = lldb_modify,
-       .delete_record = lldb_delete,
-       .rename_record = lldb_rename,
-       .named_lock    = lldb_lock,
-       .named_unlock  = lldb_unlock,
-       .errstring     = lldb_errstring
+       .name              = "ldap",
+       .search            = lldb_search,
+       .search_bytree     = lldb_search_bytree,
+       .add_record        = lldb_add,
+       .modify_record     = lldb_modify,
+       .delete_record     = lldb_delete,
+       .rename_record     = lldb_rename,
+       .start_transaction = lldb_start_trans,
+       .end_transaction   = lldb_end_trans,
+       .errstring         = lldb_errstring
 };
 
 
index f136fb70725fbe54508e96b473db0c00644c1233..c0adab7bc3fce8bcea63c80aeb862790f1835c04 100644 (file)
@@ -457,57 +457,6 @@ static char *parsetree_to_sql(struct ldb_module *module,
        return NULL;
 }
 
-/* obtain a named lock */
-static int
-lsqlite3_lock(struct ldb_module * module,
-              const char * lockname)
-{
-       struct lsqlite3_private *   lsqlite3 = module->private_data;
-
-/* FIXME
-       if (lockname == NULL) {
-               return -1;
-       }
-        
-        if (strcmp(lockname, "transaction") == 0) {
-                if (lsqlite3->lock_count == 0) {
-                        if (query_norows(lsqlite3, "BEGIN EXCLUSIVE;") != 0) {
-                                return -1;
-                        }
-                }
-                ++lsqlite3->lock_count;
-        }
-*/
-       return 0;
-}
-
-/* release a named lock */
-static int
-lsqlite3_unlock(struct ldb_module *module,
-                const char *lockname)
-{
-       struct lsqlite3_private *   lsqlite3 = module->private_data;
-
-/* FIXME
-       if (lockname == NULL) {
-               return -1;
-       }
-        
-        if (strcmp(lockname, "transaction") == 0) {
-                if (lsqlite3->lock_count == 1) {
-                        if (query_norows(lsqlite3, "COMMIT;") != 0) {
-                                query_norows(lsqlite3, "ROLLBACK;");
-                        }
-                } else if (lsqlite3->lock_count > 0) {
-                        --lsqlite3->lock_count;
-                }
-        } else if (strcmp(lockname, "rollback") == 0) {
-                query_norows(lsqlite3, "ROLLBACK;");
-        }
-*/
-        return 0;
-}
-
 /*
  * query_int()
  *
@@ -685,7 +634,7 @@ static int lsqlite3_safe_rollback(sqlite3 *sqlite)
        ret = sqlite3_exec(sqlite, "ROLLBACK;", NULL, NULL, &errmsg);
        if (ret != SQLITE_OK) {
                if (errmsg) {
-                       printf("lsqlite3_safe_rollback: Serious Error: %s\n", errmsg);
+                       printf("lsqlite3_safe_rollback: Error: %s\n", errmsg);
                        free(errmsg);
                }
                return -1;
@@ -1078,7 +1027,6 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
        char *dn, *ndn;
        char *errmsg;
        char *query;
-       int rollback = 0;
        int ret;
        int i;
         
@@ -1115,8 +1063,6 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
        if (dn == NULL || ndn == NULL) goto failed;
 
        query = lsqlite3_tprintf(local_ctx,
-                                  /* Begin the transaction */
-                                  "BEGIN EXCLUSIVE; "
                                   /* Add new entry */
                                   "INSERT OR ABORT INTO ldb_entry "
                                   "('dn', 'norm_dn') "
@@ -1130,10 +1076,8 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
                        printf("lsqlite3_add: exec error: %s\n", errmsg);
                        free(errmsg);
                }
-               lsqlite3_safe_rollback(lsqlite3->sqlite); 
                goto failed;
        }
-       rollback = 1;
 
        eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, local_ctx, ndn);
        if (eid == -1) goto failed;
@@ -1179,20 +1123,10 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
                }
        }
 
-       ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg);
-       if (ret != SQLITE_OK) {
-               if (errmsg) {
-                       printf("lsqlite3_add: commit error: %s\n", errmsg);
-                       free(errmsg);
-               }
-               goto failed;
-       }
-
        talloc_free(local_ctx);
         return 0;
 
 failed:
-       if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); 
        talloc_free(local_ctx);
        return -1;
 }
@@ -1205,7 +1139,6 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
        struct lsqlite3_private *lsqlite3 = module->private_data;
         long long eid;
        char *errmsg;
-       int rollback = 0;
        int ret;
        int i;
         
@@ -1235,16 +1168,6 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
                 return 0;
        }
 
-       ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN EXCLUSIVE;", NULL, NULL, &errmsg);
-       if (ret != SQLITE_OK) {
-               if (errmsg) {
-                       printf("lsqlite3_modify: error: %s\n", errmsg);
-                       free(errmsg);
-               }
-               goto failed;
-       }
-       rollback = 1;
-
        eid = lsqlite3_get_eid(module, msg->dn);
        if (eid == -1) {
                goto failed;
@@ -1376,20 +1299,10 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
                }
        }
 
-       ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg);
-       if (ret != SQLITE_OK) {
-               if (errmsg) {
-                       printf("lsqlite3_modify: error: %s\n", errmsg);
-                       free(errmsg);
-               }
-               goto failed;
-       }
-
        talloc_free(local_ctx);
         return 0;
 
 failed:
-       if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); 
        talloc_free(local_ctx);
        return -1;
 }
@@ -1419,14 +1332,10 @@ static int lsqlite3_delete(struct ldb_module *module, const struct ldb_dn *dn)
        if (eid == -1) goto failed;
 
        query = lsqlite3_tprintf(local_ctx,
-                                  /* Begin the transaction */
-                                  "BEGIN EXCLUSIVE; "
                                   /* Delete entry */
                                   "DELETE FROM ldb_entry WHERE eid = %lld; "
                                   /* Delete attributes */
-                                  "DELETE FROM ldb_attribute_values WHERE eid = %lld; "
-                                  /* Commit */
-                                  "COMMIT;",
+                                  "DELETE FROM ldb_attribute_values WHERE eid = %lld; ",
                                eid, eid);
        if (query == NULL) goto failed;
 
@@ -1436,7 +1345,6 @@ static int lsqlite3_delete(struct ldb_module *module, const struct ldb_dn *dn)
                        printf("lsqlite3_delete: error getting eid: %s\n", errmsg);
                        free(errmsg);
                }
-               lsqlite3_safe_rollback(lsqlite3->sqlite);
                goto failed;
        }
 
@@ -1500,6 +1408,49 @@ failed:
        talloc_free(local_ctx);
        return -1;
 }
+
+static int lsqlite3_start_trans(struct ldb_module * module)
+{
+       int ret;
+       char *errmsg;
+       struct lsqlite3_private *   lsqlite3 = module->private_data;
+
+       ret = sqlite3_exec(lsqlite3->sqlite, "BEGIN IMMEDIATE;", NULL, NULL, &errmsg);
+       if (ret != SQLITE_OK) {
+               if (errmsg) {
+                       printf("lsqlite3_start_trans: error: %s\n", errmsg);
+                       free(errmsg);
+               }
+               return -1;
+       }
+
+       return 0;
+}
+
+static int lsqlite3_end_trans(struct ldb_module *module, int status)
+{
+       int ret;
+       char *errmsg;
+       struct lsqlite3_private *lsqlite3 = module->private_data;
+
+       if (status == 0) {
+               ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg);
+               if (ret != SQLITE_OK) {
+                       if (errmsg) {
+                               printf("lsqlite3_end_trans: error: %s\n", errmsg);
+                               free(errmsg);
+                       }
+                       return -1;
+               }
+       } else {
+               return lsqlite3_safe_rollback(lsqlite3->sqlite);
+       }
+
+        return 0;
+}
+
+
+
 /* return extended error information */
 static const char *
 lsqlite3_errstring(struct ldb_module *module)
@@ -1799,16 +1750,16 @@ destructor(void *p)
  * Table of operations for the sqlite3 backend
  */
 static const struct ldb_module_ops lsqlite3_ops = {
-       .name          = "sqlite",
-       .search        = lsqlite3_search,
-       .search_bytree = lsqlite3_search_bytree,
-       .add_record    = lsqlite3_add,
-       .modify_record = lsqlite3_modify,
-       .delete_record = lsqlite3_delete,
-       .rename_record = lsqlite3_rename,
-       .named_lock    = lsqlite3_lock,
-       .named_unlock  = lsqlite3_unlock,
-       .errstring     = lsqlite3_errstring
+       .name              = "sqlite",
+       .search            = lsqlite3_search,
+       .search_bytree     = lsqlite3_search_bytree,
+       .add_record        = lsqlite3_add,
+       .modify_record     = lsqlite3_modify,
+       .delete_record     = lsqlite3_delete,
+       .rename_record     = lsqlite3_rename,
+       .start_transaction = lsqlite3_start_trans,
+       .end_transaction   = lsqlite3_end_trans,
+       .errstring         = lsqlite3_errstring
 };
 
 /*
index 61d0f9b64a4051a664a8186fc5193bc466bf3729..c3f59a2dbe5ded2e1a2f23db0e945010019f8274 100644 (file)
@@ -825,6 +825,19 @@ failed:
        return -1;
 }
 
+static int ltdb_start_trans(struct ldb_module *module)
+{
+       /* TODO: implement transactions */
+
+       return 0;
+}
+
+static int ltdb_end_trans(struct ldb_module *module, int status)
+{
+       /* TODO: implement transactions */
+
+       return status;
+}
 
 /*
   return extended error information
@@ -840,16 +853,16 @@ static const char *ltdb_errstring(struct ldb_module *module)
 
 
 static const struct ldb_module_ops ltdb_ops = {
-       .name          = "tdb",
-       .search        = ltdb_search,
-       .search_bytree = ltdb_search_bytree,
-       .add_record    = ltdb_add,
-       .modify_record = ltdb_modify,
-       .delete_record = ltdb_delete,
-       .rename_record = ltdb_rename,
-       .named_lock    = ltdb_lock,
-       .named_unlock  = ltdb_unlock,
-       .errstring     = ltdb_errstring
+       .name              = "tdb",
+       .search            = ltdb_search,
+       .search_bytree     = ltdb_search_bytree,
+       .add_record        = ltdb_add,
+       .modify_record     = ltdb_modify,
+       .delete_record     = ltdb_delete,
+       .rename_record     = ltdb_rename,
+       .start_transaction = ltdb_start_trans,
+       .end_transaction   = ltdb_end_trans,
+       .errstring         = ltdb_errstring
 };
 
 
index ba98a5f495a2ee97c96c0a565bb5535b0725ddc2..93ae13ffc29e70e71ee8fcdccea84b9b84f433b8 100644 (file)
@@ -1256,14 +1256,14 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
        return (mp_ret == -1 || fb_ret == -1)?-1:0;
 }
 
-static int map_lock(struct ldb_module *module, const char *lockname)
+static int map_start_trans(struct ldb_module *module)
 {
-       return ldb_next_named_lock(module, lockname);
+       return ldb_next_start_trans(module);
 }
 
-static int map_unlock(struct ldb_module *module, const char *lockname)
+static int map_end_trans(struct ldb_module *module, int status)
 {
-       return ldb_next_named_unlock(module, lockname);
+       return ldb_next_end_trans(module, status);
 }
 
 /*
@@ -1280,16 +1280,16 @@ static const char *map_errstring(struct ldb_module *module)
 }
 
 static const struct ldb_module_ops map_ops = {
-       .name          = "map",
-       .search        = map_search,
-       .search_bytree = map_search_bytree,
-       .add_record    = map_add,
-       .modify_record = map_modify,
-       .delete_record = map_delete,
-       .rename_record = map_rename,
-       .named_lock    = map_lock,
-       .named_unlock  = map_unlock,
-       .errstring     = map_errstring
+       .name              = "map",
+       .search            = map_search,
+       .search_bytree     = map_search_bytree,
+       .add_record        = map_add,
+       .modify_record     = map_modify,
+       .delete_record     = map_delete,
+       .rename_record     = map_rename,
+       .start_transaction = map_start_trans,
+       .end_transaction   = map_end_trans,
+       .errstring         = map_errstring
 };
 
 static char *map_find_url(struct ldb_context *ldb, const char *name)
index 09e9c72811931122f5935876e37926bd0af84459..ed5400176ce6c836f020d4e62ebeb84136552c53 100644 (file)
@@ -217,16 +217,16 @@ static int rdn_name_rename_record(struct ldb_module *module, const struct ldb_dn
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int rdn_name_lock(struct ldb_module *module, const char *lockname)
+static int rdn_start_trans(struct ldb_module *module)
 {
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_lock\n");
-       return ldb_next_named_lock(module, lockname);
+       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_start_trans\n");
+       return ldb_next_start_trans(module);
 }
 
-static int rdn_name_unlock(struct ldb_module *module, const char *lockname)
+static int rdn_end_trans(struct ldb_module *module, int status)
 {
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_unlock\n");
-       return ldb_next_named_unlock(module, lockname);
+       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_end_trans\n");
+       return ldb_next_end_trans(module, status);
 }
 
 /* return extended error information */
@@ -254,16 +254,16 @@ static int rdn_name_destructor(void *module_ctx)
 }
 
 static const struct ldb_module_ops rdn_name_ops = {
-       .name          = "rdn_name",
-       .search        = rdn_name_search,
-       .search_bytree = rdn_name_search_bytree,
-       .add_record    = rdn_name_add_record,
-       .modify_record = rdn_name_modify_record,
-       .delete_record = rdn_name_delete_record,
-       .rename_record = rdn_name_rename_record,
-       .named_lock    = rdn_name_lock,
-       .named_unlock  = rdn_name_unlock,
-       .errstring     = rdn_name_errstring
+       .name              = "rdn_name",
+       .search            = rdn_name_search,
+       .search_bytree     = rdn_name_search_bytree,
+       .add_record        = rdn_name_add_record,
+       .modify_record     = rdn_name_modify_record,
+       .delete_record     = rdn_name_delete_record,
+       .rename_record     = rdn_name_rename_record,
+       .start_transaction = rdn_start_trans,
+       .end_transaction   = rdn_end_trans,
+       .errstring         = rdn_name_errstring
 };
 
 
index baf038de0cd93f75c6bedf020021798fc72333c9..9406d54ce7eb7ae458757858bf06403ca4a5e76a 100644 (file)
@@ -501,12 +501,12 @@ static int schema_rename_record(struct ldb_module *module, const struct ldb_dn *
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int schema_named_lock(struct ldb_module *module, const char *name) {
-       return ldb_next_named_lock(module, name);
+static int schema_start_trans(struct ldb_module *module) {
+       return ldb_next_start_trans(module);
 }
 
-static int schema_named_unlock(struct ldb_module *module, const char *name) {
-       return ldb_next_named_unlock(module, name);
+static int schema_end_trans(struct ldb_module *module, int status) {
+       return ldb_next_end_trans(module, status);
 }
 
 /* return extended error information */
@@ -533,16 +533,16 @@ static int schema_destructor(void *module_ctx)
 }
 
 static const struct ldb_module_ops schema_ops = {
-       .name          = "schema",
-       .search        = schema_search,
-       .search_bytree = schema_search_bytree,
-       .add_record    = schema_add_record,
-       .modify_record = schema_modify_record,
-       .delete_record = schema_delete_record,
-       .rename_record = schema_rename_record,
-       .named_lock    = schema_named_lock,
-       .named_unlock  = schema_named_unlock,
-       .errstring     = schema_errstring,
+       .name              = "schema",
+       .search            = schema_search,
+       .search_bytree     = schema_search_bytree,
+       .add_record        = schema_add_record,
+       .modify_record     = schema_modify_record,
+       .delete_record     = schema_delete_record,
+       .rename_record     = schema_rename_record,
+       .start_transaction = schema_start_trans,
+       .end_transaction   = schema_end_trans,
+       .errstring         = schema_errstring,
 };
 
 #ifdef HAVE_DLOPEN_DISABLED
index 57c89a6a65c755a5f5db90c8911eeb4dc2a1b771..37c0417c6449467872cd0571939ce17049d0d76e 100644 (file)
@@ -73,16 +73,16 @@ static int skel_rename_record(struct ldb_module *module, const struct ldb_dn *ol
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-/* named_lock */
-static int skel_named_lock(struct ldb_module *module, const char *lockname)
+/* start a transaction */
+static int skel_start_trans(struct ldb_module *module)
 {
-       return ldb_next_named_lock(module, lockname);
+       return ldb_next_start_trans(module);
 }
 
-/* named_unlock */
-static int skel_named_unlock(struct ldb_module *module, const char *lockname)
+/* end a transaction */
+static int skel_end_trans(struct ldb_module *module, int status)
 {
-       return ldb_next_named_unlock(module, lockname);
+       return ldb_next_end_trans(module, status);
 }
 
 /* return extended error information */
@@ -101,16 +101,16 @@ static int skel_destructor(void *module_ctx)
 }
 
 static const struct ldb_module_ops skel_ops = {
-       .name           = "skel",
-       .search         = skel_search,
-       .search_bytree  = skel_search_bytree,
-       .add_record     = skel_add_record,
-       .modify_record  = skel_modify_record,
-       .delete_record  = skel_delete_record,
-       .rename_record  = skel_rename_record,
-       .named_lock     = skel_named_lock,
-       .named_unlock   = skel_named_unlock,
-       .errstring      = skel_errstring
+       .name              = "skel",
+       .search            = skel_search,
+       .search_bytree     = skel_search_bytree,
+       .add_record        = skel_add_record,
+       .modify_record     = skel_modify_record,
+       .delete_record     = skel_delete_record,
+       .rename_record     = skel_rename_record,
+       .start_transaction = skel_start_trans,
+       .end_transaction   = skel_end_trans,
+       .errstring         = skel_errstring
 };
 
 #ifdef HAVE_DLOPEN_DISABLED
index f71250521143cd0bcb16305c69045d3390df277e..6687b1929db2fcbf694c0595cd2e21b0539614ff 100644 (file)
@@ -215,16 +215,16 @@ static int timestamps_rename_record(struct ldb_module *module, const struct ldb_
        return ldb_next_rename_record(module, olddn, newdn);
 }
 
-static int timestamps_lock(struct ldb_module *module, const char *lockname)
+static int timestamps_start_trans(struct ldb_module *module)
 {
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_lock\n");
-       return ldb_next_named_lock(module, lockname);
+       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_start_trans\n");
+       return ldb_next_start_trans(module);
 }
 
-static int timestamps_unlock(struct ldb_module *module, const char *lockname)
+static int timestamps_end_trans(struct ldb_module *module, int status)
 {
-       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_unlock\n");
-       return ldb_next_named_unlock(module, lockname);
+       ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_end_trans\n");
+       return ldb_next_end_trans(module, status);
 }
 
 /* return extended error information */
@@ -252,16 +252,16 @@ static int timestamps_destructor(void *module_ctx)
 }
 
 static const struct ldb_module_ops timestamps_ops = {
-       .name          = "timestamps",
-       .search        = timestamps_search,
-       .search_bytree = timestamps_search_bytree,
-       .add_record    = timestamps_add_record,
-       .modify_record = timestamps_modify_record,
-       .delete_record = timestamps_delete_record,
-       .rename_record = timestamps_rename_record,
-       .named_lock    = timestamps_lock,
-       .named_unlock  = timestamps_unlock,
-       .errstring     = timestamps_errstring
+       .name              = "timestamps",
+       .search            = timestamps_search,
+       .search_bytree     = timestamps_search_bytree,
+       .add_record        = timestamps_add_record,
+       .modify_record     = timestamps_modify_record,
+       .delete_record     = timestamps_delete_record,
+       .rename_record     = timestamps_rename_record,
+       .start_transaction = timestamps_start_trans,
+       .end_transaction   = timestamps_end_trans,
+       .errstring         = timestamps_errstring
 };
 
 
index ef295b7411a1478e98f39df35f99fda4a477a99a..68d3ab24840aac95ef9a80ff3a020a5ae85baf28 100644 (file)
@@ -64,11 +64,12 @@ static void add_records(struct ldb_context *ldb,
        struct ldb_message msg;
        int i;
 
+#if 0
         if (ldb_lock(ldb, "transaction") != 0) {
                 printf("transaction lock failed\n");
                 exit(1);
         }
-
+#endif
        for (i=0;i<count;i++) {
                struct ldb_message_element el[6];
                struct ldb_val vals[6][1];
@@ -135,12 +136,12 @@ static void add_records(struct ldb_context *ldb,
 
                talloc_free(tmp_ctx);
        }
-
+#if 0
         if (ldb_unlock(ldb, "transaction") != 0) {
                 printf("transaction unlock failed\n");
                 exit(1);
         }
-
+#endif
        printf("\n");
 }