Skip to content

Commit 166b4f4

Browse files
committed
pg_restore: fix incompatibility with old directory-format dumps.
pg_restore failed to restore large objects (blobs) out of directory-format dumps made by versions before PG v12. That's because, due to a bug fixed in commit 548e509, those old versions put the wrong filename into the BLOBS TOC entry. Said bug was harmless before v17, because we ignored the incorrect filename field --- but commit a45c78e assumed it would be correct. Reported-by: Pavel Stehule <pavel.stehule@gmail.com> Author: Pavel Stehule <pavel.stehule@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAFj8pRCrZ=_e1Rv1N+6vDaH+6gf=9A2mE2J4RvnvKA1bLiXvXA@mail.gmail.com Backpatch-through: 17
1 parent 7d4667c commit 166b4f4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/bin/pg_dump/pg_backup_directory.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,15 @@ _LoadLOs(ArchiveHandle *AH, TocEntry *te)
412412

413413
/*
414414
* Note: before archive v16, there was always only one BLOBS TOC entry,
415-
* now there can be multiple. We don't need to worry what version we are
416-
* reading though, because tctx->filename should be correct either way.
415+
* now there can be multiple. Furthermore, although the actual filename
416+
* was always "blobs.toc" before v16, the value of tctx->filename did not
417+
* match that before commit 548e50976 fixed it. For simplicity we assume
418+
* it must be "blobs.toc" in all archives before v16.
417419
*/
418-
setFilePath(AH, tocfname, tctx->filename);
420+
if (AH->version < K_VERS_1_16)
421+
setFilePath(AH, tocfname, "blobs.toc");
422+
else
423+
setFilePath(AH, tocfname, tctx->filename);
419424

420425
CFH = ctx->LOsTocFH = InitDiscoverCompressFileHandle(tocfname, PG_BINARY_R);
421426

0 commit comments

Comments
 (0)