Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xU9bX-00000000o4R-1Ohd for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Nov 2026 21:23:39 +0000 Received: from localhost ([127.0.0.1]:41862 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xU9bW-00000003jni-0DYC for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Nov 2026 21:23:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:40316) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xU9bV-00000003jna-383X for pgsql-hackers@lists.postgresql.org; Thu, 19 Nov 2026 21:23:37 +0000 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xU9bT-00000000Ydn-185K for pgsql-hackers@postgresql.org; Thu, 19 Nov 2026 21:23:36 +0000 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-4877837890fso167512fac.2 for ; Thu, 19 Nov 2026 13:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795123415; x=1795728215; darn=postgresql.org; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=rZXqstXW5988rAJZBMZGxeNwXaKW9Y8yRGkkJaeUgQ8=; b=coGsUqBSKw3A2rodIXwI4Q1WV3Ftql+jRoUrsRL+nP7F1k09lgQuNt9J0O9OGTWJvj MMTZbqPUjf4Onk+ydACv+BXags8Jx2SwjrhQDVM/YJmM36AE6u6A7zkq+m4Kxjw3AHkB Lci3XlG4Yt1qfE1wwEOqCjZKlJkA2VWVOyEvBaBpaLmJupQxHc8GDfXqVJ2JJS5rrVL8 XRkrSlK3hhWK+sQnGkjc0xhXv1JGocVHixGBmLpvVzvcp9EARMTl66erDZ89rNT8ZSeM lSd3XBcJ2SRuAfWQOAUPmcr9rNz6HCzCIwVacoCx5tBu7xodv/GTSuEUkmCtjoKeUOSS q4IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795123415; x=1795728215; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rZXqstXW5988rAJZBMZGxeNwXaKW9Y8yRGkkJaeUgQ8=; b=M0TUQBW0w5GhFNYxfbmtEB/iBSx9m0Qft3QLbNJ6/INJTHD4dPHoDoSJjMoNavyEIn 82CGinBOsAHfuCRumzHZb8w0seYl7fvi4wi0MiWksUIPlExA8kG6LuTyaXN44t+So5Vw 770XhnDwcXDUTYgYUT8jwLb1RzST3A3slb4NmI1VpkvkqFDNPiVK3eJbbp2m6shgrCS2 Exl5VbtleVnInvcQL8nkyohlExxi56nNBQGOLcwL/WcGumaLHl4bEw/e3RxFxwlwglrG ybnw3AcARU9cRhBP+W5JA1V92MRd7RJVp7BZvJl8AdcYjUmpYfNkRNrO6GgDGsZmaqjn rigQ== X-Gm-Message-State: APuU4Z8N2BqkgjWg5twx6SQ5S+eeWgbg9MIQ3Qv0PpJDokkSAbLjC6aD KQEgPKX31/Pa3+nHiOIQBk1snwiMuiKhL2CeSvfOyhG37ZjHNA4KHd3V8pzEAg== X-Gm-Gg: AYBFou3lsiV7+3zRGM+R6LDbEH3equFF8g8NZjFP4/x4NM7uwlNpxvpIaL6G3YhgxSD K8HQTpPfqwhgn9KRkhoxKKznkq+NtyNmwRutbaVGd1NxCU24MklkDgOGPhEbs7Q9osZ3zTcykQm rgwB9Kj5AQsvAN3PrE+9MTTztbq5D7HNHWpiLHsaV9Bwh3WfNJ3gr8PLnogk3VpNLPGuQcwZ5A3 iGq7NoHJlQzhRLSmfbPU1yPh/VuUmognzxw5O7+WcB/acXWnNLFzG7asjKcfKjDYezpuL9LRTUN L15P/KtBG4pf8RSeNxerVFAzkpjjHNCCTvKA52wvM6jFpIBN5LtWPYWvRQMTtJEoVqq124q1+pO 3k1XO+1f3r8pl2COo9XEuvW7QYyAEUPm+bg96Mx3JhaAEEVoN6agm+UH3FTVOrLXhg7LZqjrwwm x4zRPkjKv6Of48zvBP2VAk0ZaEJChlXV0+PRUbbrnRsL0M0sF0YcA1sE2vyFyMX/M5l+7ubCQtA Jtspf8kLdOWuLN59LQr22VcRQY7UkuHTWdsJyNMAmU2+NuUcHCoQp5BU+epQ1vYejDv9sVHZh2i xKkdpFz/3Ohkw+E7os8d3pJvbdfA5xlK5sdv6ife7o/lIH8tWYS47yQLajFisQVSHpx72kCrfH4 Ct+6xrnsDACmb5sqafsgnp3lFIpdKT9o6hlXE1ApLIApRRZ3AxZbbqWui X-Received: by 2002:a05:6808:1507:b0:4f5:20:d847 with SMTP id 5614622812f47-57a0b64ef2fmr1509739b6e.36.1795123415083; Thu, 19 Nov 2026 13:23:35 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4bc60497300sm969222fac.11.2026.11.19.13.23.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 13:23:34 -0800 (PST) Date: Thu, 19 Nov 2026 15:23:32 -0600 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: pg_restore fails on extracted tar archives with large objects Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="T/ccwhpjQ+oZSBRs" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --T/ccwhpjQ+oZSBRs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The following commands produce an error: createdb src createdb dst psql src -c "select lo_from_bytea(1, '\xff')" pg_dump -Ft -f d.tar src mkdir ex tar xf d.tar -C ex pg_restore -Fd -d dst ex pg_restore: error: could not open large object TOC file "ex/2966.dat" for input: No such file or directory This is because the tar format puts NNN.dat instead of blobs_NNN.toc into the BLOBS TOC entry. That was harmless until commit a45c78e328 (v17) taught the directory format's restore code to use the file name in the TOC entry. Commit 166b4f4560 fixed a similar problem for directory-format dumps made by versions before v12. The attached patch fixes it by constructing the file name instead of using the one in the TOC entry. Given the lack of reports, I'm guessing few users are using extracted tar archives like this, or even using the tar format at all. IMHO we should seriously consider putting the tar format on a path to deprecation, but I'll save that discussion for later. -- nathan --T/ccwhpjQ+oZSBRs Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0001-pg_restore-Fix-incompatibility-with-extracted-tar.patch From a1f54aa34f39756173de63e8528ac248c340c6bb Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 19 Nov 2026 15:14:58 -0600 Subject: [PATCH v1 1/1] pg_restore: Fix incompatibility with extracted tar dumps. pg_restore fails to restore large objects from a directory-format archive that was created by extracting a tar-format archive. That's because the tar format puts the wrong file name into the BLOBS TOC entries. This was harmless before v17, because we ignored the file name field. Commit 166b4f4560 fixed the same problem for directory-format archives made by versions before v12. To fix, construct the file name instead of using the one in the TOC entry, as we already do for those older archives. This commit doesn't change the name recorded by the tar format, as that wouldn't help with existing archives. Oversight in commit a45c78e328. Backpatch-through: 17 --- src/bin/pg_dump/pg_backup_directory.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c index 34b3b6ba7d7..e14369181f4 100644 --- a/src/bin/pg_dump/pg_backup_directory.c +++ b/src/bin/pg_dump/pg_backup_directory.c @@ -399,7 +399,6 @@ _LoadLOs(ArchiveHandle *AH, TocEntry *te) { Oid oid; lclContext *ctx = (lclContext *) AH->formatData; - lclTocEntry *tctx = (lclTocEntry *) te->formatData; CompressFileHandle *CFH; char tocfname[MAXPGPATH]; char line[MAXPGPATH]; @@ -412,11 +411,20 @@ _LoadLOs(ArchiveHandle *AH, TocEntry *te) * was always "blobs.toc" before v16, the value of tctx->filename did not * match that before commit 548e50976 fixed it. For simplicity we assume * it must be "blobs.toc" in all archives before v16. + * + * Likewise, the tar format puts the wrong filename into tctx->filename, + * which matters when reading an extracted tar archive. For simplicity we + * assume it must be "blobs_.toc" in all newer archives. */ if (AH->version < K_VERS_1_16) setFilePath(AH, tocfname, "blobs.toc"); else - setFilePath(AH, tocfname, tctx->filename); + { + char fname[MAXPGPATH]; + + snprintf(fname, MAXPGPATH, "blobs_%d.toc", te->dumpId); + setFilePath(AH, tocfname, fname); + } CFH = ctx->LOsTocFH = InitDiscoverCompressFileHandle(tocfname, PG_BINARY_R); -- 2.55.0 --T/ccwhpjQ+oZSBRs--