At 2014-09-24 14:03:41 +0300, hlinnakan...@vmware.com wrote: > > Ah, I frequently run into that too; but with pg_resetxlog.
Well, that's no fun. Patch attached. -- Abhijit
>From 23fc4d90d0353e1c6d65ca5715fc0338199f01cf Mon Sep 17 00:00:00 2001 From: Abhijit Menon-Sen <a...@2ndquadrant.com> Date: Wed, 24 Sep 2014 16:48:36 +0530 Subject: Make pg_resetxlog also accept -D datadir --- src/bin/pg_resetxlog/pg_resetxlog.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c index 302d005..3b43aff 100644 --- a/src/bin/pg_resetxlog/pg_resetxlog.c +++ b/src/bin/pg_resetxlog/pg_resetxlog.c @@ -89,7 +89,7 @@ main(int argc, char *argv[]) MultiXactId set_oldestmxid = 0; char *endptr; char *endptr2; - char *DataDir; + char *DataDir = NULL; int fd; set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_resetxlog")); @@ -111,10 +111,14 @@ main(int argc, char *argv[]) } - while ((c = getopt(argc, argv, "fl:m:no:O:x:e:")) != -1) + while ((c = getopt(argc, argv, "D:fl:m:no:O:x:e:")) != -1) { switch (c) { + case 'D': + DataDir = optarg; + break; + case 'f': force = true; break; @@ -233,7 +237,7 @@ main(int argc, char *argv[]) } } - if (optind == argc) + if (DataDir == NULL && optind == argc) { fprintf(stderr, _("%s: no data directory specified\n"), progname); fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); @@ -257,7 +261,8 @@ main(int argc, char *argv[]) } #endif - DataDir = argv[optind]; + if (DataDir == NULL) + DataDir = argv[optind]; if (chdir(DataDir) < 0) { -- 1.9.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers