From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: pg_upgrade: Error out on too many command-line arguments
Date: Sun, 25 Aug 2019 10:51:47 +0200
Message-ID: <f2554627-04e7-383a-ef01-ab99bb6a291c@2ndquadrant.com> (raw)
I propose the attached patch to make pg_upgrade error out on too many
command-line arguments. This makes it match the behavior of other
PostgreSQL programs.
See [0] for an issue related to the lack of this check:
[0]:
https://www.postgresql.org/message-id/871sdbzizp.fsf%40jsievers.enova.com
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 64bbb562b90bd6272988c608524da2339323f114 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sun, 25 Aug 2019 10:46:07 +0200
Subject: [PATCH] pg_upgrade: Error out on too many command-line arguments
This makes it match the behavior of other PostgreSQL programs.
pg_upgrade doesn't take any non-option arguments, so these are always
a mistake.
---
src/bin/pg_upgrade/option.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.cindex e4093ed5af..6afdbeabc8 100644--- a/src/bin/pg_upgrade/option.c+++ b/src/bin/pg_upgrade/option.c@@ -218,6 +218,9 @@ parseCommandLine(int argc, char *argv[])
}
}
+ if (optind < argc)+ pg_fatal("too many command-line arguments (first is \"%s\")\n", argv[optind]);+
if ((log_opts.internal = fopen_priv(INTERNAL_LOG_FILE, "a")) == NULL)
pg_fatal("could not open log file \"%s\": %m\n", INTERNAL_LOG_FILE);
--
2.22.0
Attachments:
[text/plain] 0001-pg_upgrade-Error-out-on-too-many-command-line-argume.patch (960B, ../f2554627-04e7-383a-ef01-ab99bb6a291c@2ndquadrant.com/2-0001-pg_upgrade-Error-out-on-too-many-command-line-argume.patch)
download | inline diff:
From 64bbb562b90bd6272988c608524da2339323f114 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sun, 25 Aug 2019 10:46:07 +0200
Subject: [PATCH] pg_upgrade: Error out on too many command-line arguments
This makes it match the behavior of other PostgreSQL programs.
pg_upgrade doesn't take any non-option arguments, so these are always
a mistake.
---
src/bin/pg_upgrade/option.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.cindex e4093ed5af..6afdbeabc8 100644--- a/src/bin/pg_upgrade/option.c+++ b/src/bin/pg_upgrade/option.c@@ -218,6 +218,9 @@ parseCommandLine(int argc, char *argv[])
}
}
+ if (optind < argc)+ pg_fatal("too many command-line arguments (first is \"%s\")\n", argv[optind]);+
if ((log_opts.internal = fopen_priv(INTERNAL_LOG_FILE, "a")) == NULL)
pg_fatal("could not open log file \"%s\": %m\n", INTERNAL_LOG_FILE);
--
2.22.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com
Subject: Re: pg_upgrade: Error out on too many command-line arguments
In-Reply-To: <f2554627-04e7-383a-ef01-ab99bb6a291c@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox