1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Fix pg_restore to complain if any arguments remain after parsing the switches

and input file name, per bug #5617 from Leo Shklovskii.  Rearrange the
corresponding code in pg_dump and pg_dumpall so that all three programs
handle this in a consistent, straightforward fashion.

Back-patch to 9.0, but no further.  Although this is certainly a bug, it's
possible that people have scripts that will be broken by the added error
check, so it seems better not to change the behavior in stable branches.
This commit is contained in:
Tom Lane
2010-08-13 14:38:04 +00:00
parent 9b0a86861a
commit e4155c8483
3 changed files with 41 additions and 28 deletions

View File

@@ -25,7 +25,7 @@
* http://archives.postgresql.org/pgsql-bugs/2010-02/msg00187.php
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.584 2010/08/03 19:24:04 tgl Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.585 2010/08/13 14:38:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -480,19 +480,20 @@ main(int argc, char **argv)
}
}
if (optind < (argc - 1))
/* Get database name from command line */
if (optind < argc)
dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
{
fprintf(stderr, _("%s: too many command-line arguments (first is \"%s\")\n"),
progname, argv[optind + 1]);
progname, argv[optind]);
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
progname);
exit(1);
}
/* Get database name from command line */
if (optind < argc)
dbname = argv[optind];
/* --column-inserts implies --inserts */
if (column_inserts)
dump_inserts = 1;