Author: tridge Date: 2005-09-22 04:16:46 +0000 (Thu, 22 Sep 2005) New Revision: 10406
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10406 Log: added --nosync option to all ldb tools, so that you can control if transactions are synchronous or not on the command line. add LDB_FLG_NOSYNC flag to ldb_connect() so we can make our temporary ldb databases non-synchronous Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h branches/SAMBA_4_0/source/lib/ldb/tools/ldbtest.c Changeset: Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2005-09-22 04:16:46 UTC (rev 10406) @@ -158,6 +158,7 @@ }; #define LDB_FLG_RDONLY 1 +#define LDB_FLG_NOSYNC 2 #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2005-09-22 04:16:46 UTC (rev 10406) @@ -1522,7 +1522,7 @@ */ static int initialize(struct lsqlite3_private *lsqlite3, - struct ldb_context *ldb, const char *url) + struct ldb_context *ldb, const char *url, int flags) { TALLOC_CTX *local_ctx; long long queryInt; @@ -1648,14 +1648,16 @@ goto failed; } - /* DANGEROUS */ - ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg); - if (ret != SQLITE_OK) { - if (errmsg) { - printf("lsqlite3 initializaion error: %s\n", errmsg); - free(errmsg); + if (flags & LDB_FLG_NOSYNC) { + /* DANGEROUS */ + ret = sqlite3_exec(lsqlite3->sqlite, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg); + if (ret != SQLITE_OK) { + if (errmsg) { + printf("lsqlite3 initializaion error: %s\n", errmsg); + free(errmsg); + } + goto failed; } - goto failed; } /* */ @@ -1836,7 +1838,7 @@ lsqlite3->options = NULL; lsqlite3->trans_count = 0; - ret = initialize(lsqlite3, ldb, url); + ret = initialize(lsqlite3, ldb, url, flags); if (ret != SQLITE_OK) { goto failed; } Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2005-09-22 04:16:46 UTC (rev 10406) @@ -895,11 +895,10 @@ tdb_flags = TDB_DEFAULT; -#if 0 - /* set this to run tdb without disk sync, but still with - transactions */ - tdb_flags |= TDB_NOSYNC; -#endif + /* check for the 'nosync' option */ + if (flags & LDB_FLG_NOSYNC) { + tdb_flags |= TDB_NOSYNC; + } if (flags & LDB_FLG_RDONLY) { open_flags = O_RDONLY; Modified: branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.c 2005-09-22 04:16:46 UTC (rev 10406) @@ -55,6 +55,7 @@ { "num-searches", 0, POPT_ARG_INT, &options.num_searches, 0, "number of test searches", NULL }, { "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL }, { "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL }, + { "nosync", 0, POPT_ARG_NONE, &options.nosync, 0, "non-synchronous transactions", NULL }, { "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL }, { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" }, { "input", 'I', POPT_ARG_STRING, &options.input, 0, "Input File", "Input" }, @@ -159,7 +160,11 @@ } if (strcmp(ret->url, "NONE") != 0) { - if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) { + int flags = 0; + if (options.nosync) { + flags |= LDB_FLG_NOSYNC; + } + if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) { fprintf(stderr, "Failed to connect to %s - %s\n", ret->url, ldb_errstring(ldb)); goto failed; Modified: branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/tools/cmdline.h 2005-09-22 04:16:46 UTC (rev 10406) @@ -34,6 +34,7 @@ int verbose; int recursive; int all_records; + int nosync; const char **options; int argc; const char **argv; Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbtest.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/tools/ldbtest.c 2005-09-22 03:56:41 UTC (rev 10405) +++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbtest.c 2005-09-22 04:16:46 UTC (rev 10406) @@ -299,7 +299,12 @@ struct ldb_dn *indexlist; struct ldb_dn *basedn; int ret; + int flags = 0; + if (options->nosync) { + flags |= LDB_FLG_NOSYNC; + } + printf("Starting index test\n"); indexlist = ldb_dn_explode(NULL, "@INDEXLIST"); @@ -337,7 +342,7 @@ (*ldb) = ldb_init(options); - ret = ldb_connect(*ldb, options->url, 0, NULL); + ret = ldb_connect(*ldb, options->url, flags, NULL); if (ret != 0) { printf("failed to connect to %s\n", options->url); exit(1);
