diff options
Diffstat (limited to 'src/bin/pg_dump/pg_backup_archiver.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 66123094fe8..7d895c46a38 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -665,6 +665,7 @@ NewRestoreOptions(void) /* set any fields that shouldn't default to zeroes */ opts->format = archUnknown; opts->promptPassword = TRI_DEFAULT; + opts->dumpSections = DUMP_UNSECTIONED; return opts; } @@ -2120,6 +2121,7 @@ ReadToc(ArchiveHandle *AH) int depIdx; int depSize; TocEntry *te; + bool in_post_data = false; AH->tocCount = ReadInt(AH); AH->maxDumpId = 0; @@ -2185,6 +2187,12 @@ ReadToc(ArchiveHandle *AH) te->section = SECTION_PRE_DATA; } + /* will stay true even for SECTION_NONE items */ + if (te->section == SECTION_POST_DATA) + in_post_data = true; + + te->inPostData = in_post_data; + te->defn = ReadStr(AH); te->dropStmt = ReadStr(AH); @@ -2334,6 +2342,17 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls) if (!ropt->createDB && strcmp(te->desc, "DATABASE") == 0) return 0; + /* skip (all but) post data section as required */ + /* table data is filtered if necessary lower down */ + if (ropt->dumpSections != DUMP_UNSECTIONED) + { + if (!(ropt->dumpSections & DUMP_POST_DATA) && te->inPostData) + return 0; + if (!(ropt->dumpSections & DUMP_PRE_DATA) && ! te->inPostData && strcmp(te->desc, "TABLE DATA") != 0) + return 0; + } + + /* Check options for selective dump/restore */ if (ropt->schemaNames) { |