From f320e3a659d2ef701e3770071375ca9781d98325 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2008 14:39:42 +1100 Subject: 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. --- source4/lib/ldb/tools/ldbadd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/ldb/tools/ldbadd.c') diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c index 15376e7342..3749aec629 100644 --- a/source4/lib/ldb/tools/ldbadd.c +++ b/source4/lib/ldb/tools/ldbadd.c @@ -92,6 +92,11 @@ int main(int argc, const char **argv) options = ldb_cmdline_process(ldb, argc, argv, usage); + if (ldb_transaction_start(ldb) != 0) { + printf("Failed to start transaction\n"); + exit(1); + } + if (options->argc == 0) { ret = process_file(ldb, stdin, &count); } else { @@ -108,6 +113,11 @@ int main(int argc, const char **argv) } } + if (count != 0 && ldb_transaction_commit(ldb) != 0) { + printf("Failed to commit transaction\n"); + exit(1); + } + talloc_free(ldb); printf("Added %d records with %d failures\n", count, failures); -- cgit