Skip to content

Commit 19d0c46

Browse files
committed
pg_restore failed on tar-format archives if they contained large objects
(blobs) with comments, per bug #2727 from Konstantin Pelepelin. Mea culpa for not having tested this case. Back-patch to 8.1; prior branches don't dump blob comments at all.
1 parent c1fdbba commit 19d0c46

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/bin/pg_dump/pg_backup_tar.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.55 2006/10/04 00:30:05 momjian Exp $
19+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.56 2006/11/01 15:59:26 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -701,6 +701,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
701701
lclContext *ctx = (lclContext *) AH->formatData;
702702
TAR_MEMBER *th;
703703
size_t cnt;
704+
bool foundBlob = false;
704705
char buf[4096];
705706

706707
StartRestoreBlobs(AH);
@@ -725,10 +726,22 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
725726
ahwrite(buf, 1, cnt, AH);
726727
}
727728
EndRestoreBlob(AH, oid);
729+
foundBlob = true;
728730
}
731+
tarClose(AH, th);
732+
}
733+
else
734+
{
735+
tarClose(AH, th);
736+
/*
737+
* Once we have found the first blob, stop at the first
738+
* non-blob entry (which will be 'blobs.toc'). This coding would
739+
* eat all the rest of the archive if there are no blobs ... but
740+
* this function shouldn't be called at all in that case.
741+
*/
742+
if (foundBlob)
743+
break;
729744
}
730-
731-
tarClose(AH, th);
732745

733746
th = tarOpen(AH, NULL, 'r');
734747
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy