At 2014-06-30 12:05:06 +0530, a...@2ndquadrant.com wrote:
>
> It may be that the best thing to do would be to avoid using
> optional_argument altogether, and have separate --stats and
> --stats-per-record options. Thoughts?

That's what I've done in the attached patch, except I've called the new
option --record-stats. Both options now use no_argument. This should
apply on top of the diff I posted a little while ago.

-- Abhijit
commit cc9422aa71ef0b507c634282272be3fd15c39c0b
Author: Abhijit Menon-Sen <a...@2ndquadrant.com>
Date:   Mon Jun 30 12:15:54 2014 +0530

    Introduce --record-stats to avoid use of optional_argument

diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/contrib/pg_xlogdump/pg_xlogdump.c
index 47838d4..1853b47 100644
--- a/contrib/pg_xlogdump/pg_xlogdump.c
+++ b/contrib/pg_xlogdump/pg_xlogdump.c
@@ -609,7 +609,8 @@ main(int argc, char **argv)
 		{"timeline", required_argument, NULL, 't'},
 		{"xid", required_argument, NULL, 'x'},
 		{"version", no_argument, NULL, 'V'},
-		{"stats", optional_argument, NULL, 'z'},
+		{"stats", no_argument, NULL, 'z'},
+		{"record-stats", no_argument, NULL, 'Z'},
 		{NULL, 0, NULL, 0}
 	};
 
@@ -643,7 +644,7 @@ main(int argc, char **argv)
 		goto bad_argument;
 	}
 
-	while ((option = getopt_long(argc, argv, "be:?fn:p:r:s:t:Vx:z::",
+	while ((option = getopt_long(argc, argv, "be:?fn:p:r:s:t:Vx:zZ",
 								 long_options, &optindex)) != -1)
 	{
 		switch (option)
@@ -738,18 +739,10 @@ main(int argc, char **argv)
 				break;
 			case 'z':
 				config.stats = true;
-				config.stats_per_record = false;
-				if (optarg)
-				{
-					if (strcmp(optarg, "record") == 0)
-						config.stats_per_record = true;
-					else if (strcmp(optarg, "rmgr") != 0)
-					{
-						fprintf(stderr, "%s: unrecognised argument to --stats: %s\n",
-								progname, optarg);
-						goto bad_argument;
-					}
-				}
+				break;
+			case 'Z':
+				config.stats = true;
+				config.stats_per_record = true;
 				break;
 			default:
 				goto bad_argument;
diff --git a/doc/src/sgml/pg_xlogdump.sgml b/doc/src/sgml/pg_xlogdump.sgml
index d9f4a6a..bfd9eb9 100644
--- a/doc/src/sgml/pg_xlogdump.sgml
+++ b/doc/src/sgml/pg_xlogdump.sgml
@@ -181,12 +181,22 @@ PostgreSQL documentation
 
      <varlistentry>
       <term><option>-z</option></term>
-      <term><option>--stats[=record]</option></term>
+      <term><option>--stats</option></term>
       <listitem>
        <para>
         Display summary statistics (number and size of records and
-        full-page images) instead of individual records. Optionally
-        generate statistics per-record instead of per-rmgr.
+        full-page images per rmgr) instead of individual records.
+       </para>
+      </listitem>
+     </varlistentry>
+
+     <varlistentry>
+      <term><option>-Z</option></term>
+      <term><option>--record-stats</option></term>
+      <listitem>
+       <para>
+        Display summary statistics (number and size of records and
+        full-page images) instead of individual records.
        </para>
       </listitem>
      </varlistentry>
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to