aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/pg_backup.h3
-rw-r--r--src/bin/pg_dump/pg_backup_archiver.c19
-rw-r--r--src/bin/pg_dump/pg_restore.c7
3 files changed, 26 insertions, 3 deletions
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 6f81b8deecc..426b5110fbd 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.41 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.42 2006/08/01 18:21:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -109,6 +109,7 @@ typedef struct _restoreOptions
char *pghost;
char *username;
int ignoreVersion;
+ int noDataForFailedTables;
int requirePassword;
int exit_on_error;
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 76ebc0b89b0..6100633d56e 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.134 2006/07/18 17:42:00 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.135 2006/08/01 18:21:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -278,6 +278,23 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
_printTocEntry(AH, te, ropt, false, false);
defnDumped = true;
+ /* If we could not create a table, ignore the respective TABLE DATA if
+ * -X no-data-for-failed-tables is given */
+ if (ropt->noDataForFailedTables && AH->lastErrorTE == te && strcmp (te->desc, "TABLE") == 0) {
+ TocEntry *tes, *last;
+
+ ahlog (AH, 1, "table %s could not be created, will not restore its data\n", te->tag);
+
+ for (last = te, tes = te->next; tes != AH->toc; last = tes, tes = tes->next) {
+ if (strcmp (tes->desc, "TABLE DATA") == 0 && strcmp (tes->tag, te->tag) == 0 &&
+ strcmp (tes->namespace ? tes->namespace : "", te->namespace ? te->namespace : "") == 0) {
+ /* remove this node */
+ last->next = tes->next;
+ break;
+ }
+ }
+ }
+
/* If we created a DB, connect to it... */
if (strcmp(te->desc, "DATABASE") == 0)
{
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 410a2104f4f..474973ffda9 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.79 2006/07/14 14:52:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.80 2006/08/01 18:21:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -252,6 +252,8 @@ main(int argc, char **argv)
use_setsessauth = 1;
else if (strcmp(optarg, "disable-triggers") == 0)
disable_triggers = 1;
+ else if (strcmp(optarg, "no-data-for-failed-tables") == 0)
+ opts->noDataForFailedTables = 1;
else
{
fprintf(stderr,
@@ -397,6 +399,9 @@ usage(const char *progname)
printf(_(" -X use-set-session-authorization, --use-set-session-authorization\n"
" use SESSION AUTHORIZATION commands instead of\n"
" OWNER TO commands\n"));
+ printf(_(" -X no-data-for-failed-tables\n"
+ " do not restore data of tables which could not be\n"
+ " created\n"));
printf(_(" -1, --single-transaction restore as a single transaction\n"));
printf(_("\nConnection options:\n"));