diff options
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 8f1f6c1a24b..2344937851b 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -108,6 +108,9 @@ static void reduce_dependencies(ArchiveHandle *AH, TocEntry *te, static void mark_create_done(ArchiveHandle *AH, TocEntry *te); static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te); +static void StrictNamesCheck(RestoreOptions *ropt); + + /* * Allocate a new DumpOptions block containing all default values. */ @@ -284,6 +287,10 @@ SetArchiveRestoreOptions(Archive *AHX, RestoreOptions *ropt) te->reqs = _tocEntryRequired(te, curSection, ropt); } + + /* Enforce strict names checking */ + if (ropt->strict_names) + StrictNamesCheck(ropt); } /* Public */ @@ -1104,6 +1111,10 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt) } } + /* Enforce strict names checking */ + if (ropt->strict_names) + StrictNamesCheck(ropt); + if (ropt->filename) RestoreOutput(AH, sav); } @@ -2612,6 +2623,49 @@ processStdStringsEntry(ArchiveHandle *AH, TocEntry *te) te->defn); } +static void +StrictNamesCheck(RestoreOptions *ropt) +{ + const char *missing_name; + + Assert(ropt->strict_names); + + if (ropt->schemaNames.head != NULL) + { + missing_name = simple_string_list_not_touched(&ropt->schemaNames); + if (missing_name != NULL) + exit_horribly(modulename, "Schema \"%s\" not found.\n", missing_name); + } + + if (ropt->tableNames.head != NULL) + { + missing_name = simple_string_list_not_touched(&ropt->tableNames); + if (missing_name != NULL) + exit_horribly(modulename, "Table \"%s\" not found.\n", missing_name); + } + + if (ropt->indexNames.head != NULL) + { + missing_name = simple_string_list_not_touched(&ropt->indexNames); + if (missing_name != NULL) + exit_horribly(modulename, "Index \"%s\" not found.\n", missing_name); + } + + if (ropt->functionNames.head != NULL) + { + missing_name = simple_string_list_not_touched(&ropt->functionNames); + if (missing_name != NULL) + exit_horribly(modulename, "Function \"%s\" not found.\n", missing_name); + } + + if (ropt->triggerNames.head != NULL) + { + missing_name = simple_string_list_not_touched(&ropt->triggerNames); + if (missing_name != NULL) + exit_horribly(modulename, "Trigger \"%s\" not found.\n", missing_name); + } +} + static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt) { |