diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 7f47a7c..835f323 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -1137,6 +1137,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) int buflen; char *cmnt; char *endptr; + char *owner = NULL; DumpId id; TocEntry *te; @@ -1172,6 +1173,18 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) continue; } + /* If there is any string after ID assume it as "forced" owner. */ + while (*endptr) { + if (!isspace(*endptr) && owner == NULL) + owner = endptr; + else if (isspace(*endptr) && owner != NULL) + { + *endptr = '\0'; + break; + } + *endptr++; + } + /* Find TOC entry */ te = getTocEntryByDumpId(AH, id); if (!te) @@ -1181,6 +1194,14 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) /* Mark it wanted */ ropt->idWanted[id - 1] = true; + /* Alter TOC entry owner, if found "forced" owner. */ + if (owner != NULL) + { + write_msg(modulename, "WARNING: forcing owner for %s %s to %s\n", te->desc, te->tag, owner); + free(te->owner); + te->owner = strdup(owner); + } + /* * Move each item to the end of the list as it is selected, so that * they are placed in the desired order. Any unwanted items will end