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
exit(1);
}
}
+
+ 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);
+ }
}
static void
}
}
+ 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);
throttle_delay *= nthreads;
if (argc > optind)
- dbName = argv[optind];
+ dbName = argv[optind++];
else
{
if ((env = getenv("PGDATABASE")) != NULL && *env != '\0')
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)