summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-28 04:14:58 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:53 -0500
commitb1c80c3cfab83bad414b30ca9a7e90a6073152df (patch)
tree4facdb3ce78eaee9992295113945d416bbb9100e /source4/lib/ldb/common
parent5811b6dac51edb2b8fdb217c41a56c5122763157 (diff)
downloadsamba-b1c80c3cfab83bad414b30ca9a7e90a6073152df.tar.gz
samba-b1c80c3cfab83bad414b30ca9a7e90a6073152df.tar.bz2
samba-b1c80c3cfab83bad414b30ca9a7e90a6073152df.zip
r12534: Make the transaction code fill the error string on failure.
Andrew Bartlett (This used to be commit 2f54d7f774434f2a8b89ae01e993c4a1d16ce861)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 3dc62fd4d6..6095f4fc04 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -126,13 +126,22 @@ static void ldb_reset_err_string(struct ldb_context *ldb)
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_start(struct ldb_context *ldb)
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 @@ int ldb_transaction_commit(struct ldb_context *ldb)
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_commit(struct ldb_context *ldb)
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 @@ int ldb_transaction_cancel(struct ldb_context *ldb)
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;
}
/*