postgres.git / summary / log / commit / refs

commit    ffc0fbbd1d8a666ceadf8a801cc8d1d39ee086bc
Author:   Nathan Bossart <nathan@postgresql.org>
Date:     Mon Nov 23 18:30:41 2026 +0000

    pg_restore: Fix incompatibilities with extracted tar dumps.
    
    Extracting a tar-format archive is supposed to produce a valid
    directory-format archive.  Each BLOBS entry in the archive's table
    of contents (TOC) names a file that lists the large objects to
    restore, but the tar format puts the wrong file name into these
    entries.  As a result, pg_restore fails to restore large objects
    from an extracted tar archive, and parallel restore can't estimate
    their size.
    
    To fix, construct the file name instead of using the one in the
    TOC entry, as commit 166b4f4560 did for directory-format archives
    made by versions before v12.  This commit doesn't change the name
    recorded by the tar format, as that wouldn't help with existing
    archives.
    
    Reviewed-by: Sami Imseih <samimseih.pg@gmail.com>
    Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
    Discussion: https://postgr.es/m/av9o1Fi3PQ-jqmGO%40nathan
    Backpatch-through: 15


src/bin/pg_dump/pg_backup_directory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c index 8982176cbf7..c7f8db5c29f 100644 --- a/src/bin/pg_dump/pg_backup_directory.c +++ b/src/bin/pg_dump/pg_backup_directory.c @@ -769,8 +769,14 @@ _PrepParallelRestore(ArchiveHandle *AH) * using compression, the physical file size might not be a very good * guide to the amount of work involved in restoring the file, but we * only need an approximate indicator of that. + * + * Note that we can't rely on tctx->filename for the BLOBS entry, as + * it is wrong in some archives (e.g., extracted tar archives). */ - setFilePath(AH, fname, tctx->filename); + if (strcmp(te->desc, "BLOBS") == 0) + setFilePath(AH, fname, "blobs.toc"); + else + setFilePath(AH, fname, tctx->filename); if (stat(fname, &st) == 0) te->dataLength = st.st_size; [parent: 4bb91cc2bd13]