From df8cfdf848de9f6b49964cc776617a6cbc34a237 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 14 Mar 2018 00:45:40 +0000 Subject: [PATCH v2 4/4] 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 pg_resetwal - - + + + + + + + + option - datadir + + + + + + datadir + @@ -78,6 +90,7 @@ PostgreSQL documentation + Force pg_resetwal to proceed even if it cannot determine @@ -88,6 +101,7 @@ PostgreSQL documentation + The (no operation) option instructs @@ -124,6 +138,7 @@ PostgreSQL documentation xid,xid + xid,xid Manually set the oldest and newest transaction IDs for which the commit @@ -145,6 +160,7 @@ PostgreSQL documentation xid_epoch + xid_epoch Manually set the next transaction ID's epoch. @@ -165,6 +181,7 @@ PostgreSQL documentation walfile + walfile Manually set the WAL starting address. @@ -196,6 +213,7 @@ PostgreSQL documentation mxid,mxid + mxid,mxid Manually set the next and oldest multitransaction ID. @@ -217,6 +235,7 @@ PostgreSQL documentation oid + oid Manually set the next OID. @@ -232,6 +251,7 @@ PostgreSQL documentation mxoff + mxoff Manually set the next multitransaction offset. @@ -249,6 +269,7 @@ PostgreSQL documentation wal_segment_size + wal_segment_size Manually set the WAL segment size (in megabytes). @@ -273,6 +294,7 @@ PostgreSQL documentation xid + xid 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 604a8d2..b3c1d8d 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) { @@ -1284,19 +1299,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 .\n")); } -- 2.7.3.AMZN