1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-28 11:55:03 +03:00

Error out on too many command-line arguments

Fix up oid2name, pg_upgrade, and pgbench to error out on too many
command-line arguments.  This makes it match the behavior of other
PostgreSQL programs.

Author: Peter Eisentraut, Ibrar Ahmed
Discussion: https://www.postgresql.org/message-id/flat/f2554627-04e7-383a-ef01-ab99bb6a291c%402ndquadrant.com
This commit is contained in:
Peter Eisentraut
2019-08-29 16:19:35 +02:00
parent 317b3d7ae2
commit 9684e42695
3 changed files with 20 additions and 1 deletions

View File

@@ -5540,7 +5540,7 @@ main(int argc, char **argv)
throttle_delay *= nthreads;
if (argc > optind)
dbName = argv[optind];
dbName = argv[optind++];
else
{
if ((env = getenv("PGDATABASE")) != NULL && *env != '\0')
@@ -5551,6 +5551,14 @@ main(int argc, char **argv)
dbName = "";
}
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
}
if (is_init_mode)
{
if (benchmarking_option_set)