Author: abartlet
Date: 2005-12-28 04:14:58 +0000 (Wed, 28 Dec 2005)
New Revision: 12534

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12534

Log:
Make the transaction code fill the error string on failure.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb.c      2005-12-28 03:57:26 UTC 
(rev 12533)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb.c      2005-12-28 04:14:58 UTC 
(rev 12534)
@@ -126,13 +126,22 @@
 int ldb_transaction_start(struct ldb_context *ldb)
 {
        struct ldb_module *module;
+       int status;
        FIRST_OP(ldb, start_transaction);
        
        ldb->transaction_active++;
 
        ldb_reset_err_string(ldb);
 
-       return module->ops->start_transaction(module);
+       status = module->ops->start_transaction(module);
+       if (status != LDB_SUCCESS) {
+               if (ldb->err_string == NULL) {
+                       /* no error string was setup by the backend */
+                       ldb_set_errstring(ldb->modules, 
+                                         talloc_asprintf(ldb, "ldb transaction 
start error %d", status));
+               }
+       }
+       return status;
 }
 
 /*
@@ -141,6 +150,7 @@
 int ldb_transaction_commit(struct ldb_context *ldb)
 {
        struct ldb_module *module;
+       int status;
        FIRST_OP(ldb, end_transaction);
 
        if (ldb->transaction_active > 0) {
@@ -151,7 +161,15 @@
 
        ldb_reset_err_string(ldb);
 
-       return module->ops->end_transaction(module);
+       status = module->ops->end_transaction(module);
+       if (status != LDB_SUCCESS) {
+               if (ldb->err_string == NULL) {
+                       /* no error string was setup by the backend */
+                       ldb_set_errstring(ldb->modules, 
+                                         talloc_asprintf(ldb, "ldb transaction 
commit error %d", status));
+               }
+       }
+       return status;
 }
 
 /*
@@ -160,6 +178,7 @@
 int ldb_transaction_cancel(struct ldb_context *ldb)
 {
        struct ldb_module *module;
+       int status;
        FIRST_OP(ldb, del_transaction);
 
        if (ldb->transaction_active > 0) {
@@ -168,7 +187,15 @@
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       return module->ops->del_transaction(module);
+       status = module->ops->del_transaction(module);
+       if (status != LDB_SUCCESS) {
+               if (ldb->err_string == NULL) {
+                       /* no error string was setup by the backend */
+                       ldb_set_errstring(ldb->modules, 
+                                         talloc_asprintf(ldb, "ldb transaction 
cancel error %d", status));
+               }
+       }
+       return status;
 }
 
 /*

Reply via email to