diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-12-16 14:39:42 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-12-16 14:39:42 +1100 |
commit | f320e3a659d2ef701e3770071375ca9781d98325 (patch) | |
tree | 6111488b1156e5a22a470aa50f432ad202f2c1a2 /source4/lib/ldb/tools/ldbedit.c | |
parent | 936d76802f98d04d9743b2ca8eeeaadd4362db51 (diff) | |
download | samba-f320e3a659d2ef701e3770071375ca9781d98325.tar.gz samba-f320e3a659d2ef701e3770071375ca9781d98325.tar.bz2 samba-f320e3a659d2ef701e3770071375ca9781d98325.zip |
use transactions in ldbadd, ldbmodify and ldbedit
The command line tools ldbadd, ldbmodify and ldbedit should operate
within a transaction to make them more efficient. The ldbadd tool in
particular is much faster when adding a large number of records if all
the adds happen within a transaction. Previously there was a
transaction per record.
Diffstat (limited to 'source4/lib/ldb/tools/ldbedit.c')
-rw-r--r-- | source4/lib/ldb/tools/ldbedit.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index b2a040cd09..b18aea1b10 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -112,6 +112,11 @@ static int merge_edits(struct ldb_context *ldb, int ret = 0; int adds=0, modifies=0, deletes=0; + if (ldb_transaction_start(ldb) != 0) { + fprintf(stderr, "Failed to start transaction\n"); + return -1; + } + /* do the adds and modifies */ for (i=0;i<count2;i++) { msg = msg_find(ldb, msgs1, count1, msgs2[i]->dn); @@ -150,6 +155,11 @@ static int merge_edits(struct ldb_context *ldb, } } + if (ldb_transaction_commit(ldb) != 0) { + fprintf(stderr, "Failed to commit transaction\n"); + return -1; + } + printf("# %d adds %d modifies %d deletes\n", adds, modifies, deletes); return ret; |