summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/ref/pg_restore.sgml14
-rw-r--r--src/bin/pg_dump/pg_backup.h5
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c7
-rw-r--r--src/bin/pg_dump/pg_restore.c15
4 files changed, 30 insertions, 11 deletions
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index 533bdd9c0b8..6ffad3b5384 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.47 2004/07/13 02:59:49 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.48 2004/08/20 04:20:22 momjian Exp $ -->
<refentry id="APP-PGRESTORE">
<refmeta>
@@ -130,6 +130,18 @@
</varlistentry>
<varlistentry>
+ <term><option>-e</option></term>
+ <term><option>--exit-on-error</option></term>
+ <listitem>
+ <para>
+ Exit if an error is encountered while sending SQL commands to
+ the database. The default is to continue and to display a count of
+ errors at the end of the restoration.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>-f <replaceable>filename</replaceable></option></term>
<term><option>--file=<replaceable>filename</replaceable></option></term>
<listitem>
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 4957ea9a147..7723203df7f 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.31 2004/07/13 03:00:17 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.32 2004/08/20 04:20:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -59,7 +59,7 @@ typedef struct _Archive
int maxRemoteVersion;
/* error handling */
- bool die_on_errors; /* whether to die on sql errors... */
+ bool exit_on_error; /* whether to exit on SQL errors... */
int n_errors; /* number of errors (if no die) */
/* The rest is private */
@@ -103,6 +103,7 @@ typedef struct _restoreOptions
char *username;
int ignoreVersion;
int requirePassword;
+ int exit_on_error;
bool *idWanted;
bool limitToList;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index d528d2df578..5c610f962bc 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.92 2004/08/13 21:37:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.93 2004/08/20 04:20:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -457,6 +457,7 @@ NewRestoreOptions(void)
opts->format = archUnknown;
opts->suppressDumpWarnings = false;
+ opts->exit_on_error = false;
return opts;
}
@@ -1227,7 +1228,7 @@ warn_or_die_horribly(ArchiveHandle *AH,
{
va_list ap;
va_start(ap, fmt);
- if (AH->public.die_on_errors)
+ if (AH->public.exit_on_error)
{
_die_horribly(AH, modulename, fmt, ap);
}
@@ -1693,7 +1694,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
}
/* sql error handling */
- AH->public.die_on_errors = true;
+ AH->public.exit_on_error = true;
AH->public.n_errors = 0;
return AH;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index eef86a25e57..918a93a6568 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"));