summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_restore.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-08-20 04:20:23 +0000
committerBruce Momjian <bruce@momjian.us>2004-08-20 04:20:23 +0000
commitdaa076c4fdd32aff597eda4c34347d488c5b1e3a (patch)
tree82b9d6a320c0b8cb250fb9f4a19bf64f95233989 /src/bin/pg_dump/pg_restore.c
parent46be0c18f120466da9a9765d4ac15fdeaab4b0c7 (diff)
downloadpostgresql-daa076c4fdd32aff597eda4c34347d488c5b1e3a.tar.gz
> Please find attached a submission to add a "exit on error" option to
> pg_restore, as it seems that some people have scripts that rely on the > previous "abort on error" default behavior when restoring data with a > direct connection. > > Fabien Coelho
Diffstat (limited to 'src/bin/pg_dump/pg_restore.c')
-rw-r--r--src/bin/pg_dump/pg_restore.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index eef86a25e5..918a93a656 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -34,7 +34,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.59 2004/07/13 03:00:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.60 2004/08/20 04:20:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -90,6 +90,7 @@ main(int argc, char **argv)
{"create", 0, NULL, 'C'},
{"data-only", 0, NULL, 'a'},
{"dbname", 1, NULL, 'd'},
+ {"exit-on-error", 0, NULL, 'e'},
{"file", 1, NULL, 'f'},
{"format", 1, NULL, 'F'},
{"function", 1, NULL, 'P'},
@@ -141,7 +142,7 @@ main(int argc, char **argv)
}
}
- while ((c = getopt_long(argc, argv, "acCd:f:F:h:iI:lL:Op:P:RsS:t:T:uU:vWxX:",
+ while ((c = getopt_long(argc, argv, "acCd:ef:F:h:iI:lL:Op:P:RsS:t:T:uU:vWxX:",
cmdopts, NULL)) != -1)
{
switch (c)
@@ -159,6 +160,9 @@ main(int argc, char **argv)
case 'd':
opts->dbname = strdup(optarg);
break;
+ case 'e':
+ opts->exit_on_error = true;
+ break;
case 'f': /* output file name */
opts->filename = strdup(optarg);
break;
@@ -321,10 +325,10 @@ main(int argc, char **argv)
/* Let the archiver know how noisy to be */
AH->verbose = opts->verbose;
- /* restore keeps submitting sql commands as "pg_restore ... | psql ... "
- * this behavior choice could be turned into an option.
+ /*
+ * Whether to keep submitting sql commands as "pg_restore ... | psql ... "
*/
- AH->die_on_errors = false;
+ AH->exit_on_error = opts->exit_on_error;
if (opts->tocFile)
SortTocFromFile(AH, opts);
@@ -391,6 +395,7 @@ usage(const char *progname)
printf(_(" -p, --port=PORT database server port number\n"));
printf(_(" -U, --username=NAME connect as specified database user\n"));
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
+ printf(_(" -e, --exit-on-error exit on error, default is to continue\n"));
printf(_("\nIf no input file name is supplied, then standard input is used.\n\n"));
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));