v3-0003-Add-long-options-to-pg_resetwal.patch

application/octet-stream

Filename: v3-0003-Add-long-options-to-pg_resetwal.patch
Type: application/octet-stream
Part: 2
Message: Re: [HACKERS] pg_upgrade to clusters with a different WAL segment size

Patch

Format: format-patch
Series: patch v3-0003
Subject: Add long options to pg_resetwal.
File+
doc/src/sgml/ref/pg_resetwal.sgml 25 3
src/bin/pg_resetwal/pg_resetwal.c 30 15
From a6042d6a769d4c40b8384b6bf9c533ee293a93df Mon Sep 17 00:00:00 2001
From: Nathan Bossart <bossartn@amazon.com>
Date: Wed, 21 Mar 2018 20:03:56 +0000
Subject: [PATCH v3 3/3] Add long options to pg_resetwal.

---
 doc/src/sgml/ref/pg_resetwal.sgml | 28 +++++++++++++++++++++---
 src/bin/pg_resetwal/pg_resetwal.c | 45 ++++++++++++++++++++++++++-------------
 2 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/doc/src/sgml/ref/pg_resetwal.sgml b/doc/src/sgml/ref/pg_resetwal.sgml
index 2bffb59..ce87403 100644
--- a/doc/src/sgml/ref/pg_resetwal.sgml
+++ b/doc/src/sgml/ref/pg_resetwal.sgml
@@ -22,10 +22,22 @@ PostgreSQL documentation
  <refsynopsisdiv>
   <cmdsynopsis>
    <command>pg_resetwal</command>
-   <arg choice="opt"><option>-f</option></arg>
-   <arg choice="opt"><option>-n</option></arg>
+   <group choice="opt">
+    <arg choice="plain"><option>--force</option></arg>
+    <arg choice="plain"><option>-f</option></arg>
+   </group>
+   <group choice="opt">
+    <arg choice="plain"><option>--no-update</option></arg>
+    <arg choice="plain"><option>-n</option></arg>
+   </group>
    <arg rep="repeat"><replaceable>option</replaceable></arg>
-   <arg choice="req"><arg choice="opt"><option>-D</option></arg> <replaceable class="parameter">datadir</replaceable></arg>
+   <arg choice="req">
+    <group choice="opt">
+     <arg choice="plain"><option>--pgdata</option></arg>
+     <arg choice="plain"><option>-D</option></arg>
+    </group>
+    <replaceable class="parameter"> datadir</replaceable>
+   </arg>
   </cmdsynopsis>
  </refsynopsisdiv>
 
@@ -78,6 +90,7 @@ PostgreSQL documentation
   <variablelist>
    <varlistentry>
     <term><option>-f</option></term>
+    <term><option>--force</option></term>
     <listitem>
      <para>
       Force <command>pg_resetwal</command> to proceed even if it cannot determine
@@ -88,6 +101,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-n</option></term>
+    <term><option>--no-update</option></term>
     <listitem>
      <para>
       The <option>-n</option> (no operation) option instructs
@@ -124,6 +138,7 @@ PostgreSQL documentation
   <variablelist>
    <varlistentry>
     <term><option>-c</option> <replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></term>
+    <term><option>--xact-ids=</option><replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></term>
     <listitem>
      <para>
       Manually set the oldest and newest transaction IDs for which the commit
@@ -145,6 +160,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-e</option> <replaceable class="parameter">xid_epoch</replaceable></term>
+    <term><option>--epoch=</option><replaceable class="parameter">xid_epoch</replaceable></term>
     <listitem>
      <para>
       Manually set the next transaction ID's epoch.
@@ -165,6 +181,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-l</option> <replaceable class="parameter">walfile</replaceable></term>
+    <term><option>--wal-address=</option><replaceable class="parameter">walfile</replaceable></term>
     <listitem>
      <para>
       Manually set the WAL starting address.
@@ -196,6 +213,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-m</option> <replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></term>
+    <term><option>--multixact-ids=</option><replaceable class="parameter">mxid</replaceable>,<replaceable class="parameter">mxid</replaceable></term>
     <listitem>
      <para>
       Manually set the next and oldest multitransaction ID.
@@ -217,6 +235,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-o</option> <replaceable class="parameter">oid</replaceable></term>
+    <term><option>--next-oid=</option><replaceable class="parameter">oid</replaceable></term>
     <listitem>
      <para>
       Manually set the next OID.
@@ -232,6 +251,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-O</option> <replaceable class="parameter">mxoff</replaceable></term>
+    <term><option>--multixact-offset=</option><replaceable class="parameter">mxoff</replaceable></term>
     <listitem>
      <para>
       Manually set the next multitransaction offset.
@@ -249,6 +269,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-s</option> <replaceable class="parameter">wal_segment_size</replaceable></term>
+    <term><option>--wal-segsize=</option><replaceable class="parameter">wal_segment_size</replaceable></term>
     <listitem>
      <para>
       Manually set the WAL segment size (in megabytes).
@@ -273,6 +294,7 @@ PostgreSQL documentation
 
    <varlistentry>
     <term><option>-x</option> <replaceable class="parameter">xid</replaceable></term>
+    <term><option>--next-xact-id=</option><replaceable class="parameter">xid</replaceable></term>
     <listitem>
      <para>
       Manually set the next transaction ID.
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index 506fdda..06125f6 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -89,6 +89,21 @@ static void usage(void);
 int
 main(int argc, char *argv[])
 {
+	static struct option long_options[] = {
+		{"pgdata", required_argument, NULL, 'D'},
+		{"force", no_argument, NULL, 'f'},
+		{"no-update", no_argument, NULL, 'n'},
+		{"epoch", required_argument, NULL, 'e'},
+		{"next-xact-id", required_argument, NULL, 'x'},
+		{"xact-ids", required_argument, NULL, 'c'},
+		{"next-oid", required_argument, NULL, 'o'},
+		{"multixact-ids", required_argument, NULL, 'm'},
+		{"multixact-offset", required_argument, NULL, 'O'},
+		{"wal-address", required_argument, NULL, 'l'},
+		{"wal-segsize", required_argument, NULL, 's'},
+		{NULL, 0, NULL, 0}
+	};
+
 	int			c;
 	bool		force = false;
 	bool		noupdate = false;
@@ -118,7 +133,7 @@ main(int argc, char *argv[])
 	}
 
 
-	while ((c = getopt(argc, argv, "c:D:e:fl:m:no:O:x:s:")) != -1)
+	while ((c = getopt_long(argc, argv, "c:D:e:fl:m:no:O:x:s:", long_options, NULL)) != -1)
 	{
 		switch (c)
 		{
@@ -1275,19 +1290,19 @@ usage(void)
 	printf(_("%s resets the PostgreSQL write-ahead log.\n\n"), progname);
 	printf(_("Usage:\n  %s [OPTION]... DATADIR\n\n"), progname);
 	printf(_("Options:\n"));
-	printf(_("  -c XID,XID       set oldest and newest transactions bearing commit timestamp\n"));
-	printf(_("                   (zero in either value means no change)\n"));
-	printf(_(" [-D] DATADIR      data directory\n"));
-	printf(_("  -e XIDEPOCH      set next transaction ID epoch\n"));
-	printf(_("  -f               force update to be done\n"));
-	printf(_("  -l WALFILE       force minimum WAL starting location for new write-ahead log\n"));
-	printf(_("  -m MXID,MXID     set next and oldest multitransaction ID\n"));
-	printf(_("  -n               no update, just show what would be done (for testing)\n"));
-	printf(_("  -o OID           set next OID\n"));
-	printf(_("  -O OFFSET        set next multitransaction offset\n"));
-	printf(_("  -s SIZE          set WAL segment size (in megabytes)\n"));
-	printf(_("  -V, --version    output version information, then exit\n"));
-	printf(_("  -x XID           set next transaction ID\n"));
-	printf(_("  -?, --help       show this help, then exit\n"));
+	printf(_("  -c, --xact-ids=XID,XID          set oldest and newest transactions bearing commit timestamp\n"));
+	printf(_("                                  (zero in either value means no change)\n"));
+	printf(_(" [-D, --pgdata=]DATADIR           data directory\n"));
+	printf(_("  -e, --epoch=XIDEPOCH            set next transaction ID epoch\n"));
+	printf(_("  -f, --force                     force update to be done\n"));
+	printf(_("  -l, --wal-address=WALFILE       force minimum WAL starting location for new write-ahead log\n"));
+	printf(_("  -m, --multixact-ids=MXID,MXID   set next and oldest multitransaction ID\n"));
+	printf(_("  -n, --no-update                 no update, just show what would be done (for testing)\n"));
+	printf(_("  -o, --next-oid=OID              set next OID\n"));
+	printf(_("  -O, --multixact-offset=OFFSET   set next multitransaction offset\n"));
+	printf(_("  -s, --wal-segsize=SIZE          set WAL segment size (in megabytes)\n"));
+	printf(_("  -V, --version                   output version information, then exit\n"));
+	printf(_("  -x, --next-xact-id=XID          set next transaction ID\n"));
+	printf(_("  -?, --help                      show this help, then exit\n"));
 	printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
 }
-- 
2.7.3.AMZN