pg_dump: remove restore.sql from tar format
Thread notes
1 note#refactor
hackorum-bot#refactor
@global #refactor
Tar-format dumps include an undocumented restore.sql script that can be run
with psql after extracting the archive and hand-editing its $$PATH$$
placeholders. pg_restore never reads it. This script has needed a number
of fixes over the years (e.g., commits bf0945e863, ff75219e9f, 3c5d9d914f,
and 146e03e79a), and it still fails to restore table data for dumps taken
with --inserts. Furthermore, it is generated by a second pass over the
TOC, which forced tar-only hacks into the statistics code added by commits
7d5c83b4e9 and 9c02e3a986. Those hacks run all the attribute statistics
queries a second time just for this file.
We could spend more time fixing restore.sql, but by all indications, it
sees minimal use, and "pg_restore -f" can generate a script from the same
archive. IIRC this file was originally added in case users did not have
access to pg_restore, but that seems like a relatively unlikely situation
these days. So, I think we should just remove it, as per the attached.
Thoughts? As I've mused elsewhere, IMHO we should seriously consider
putting tar format on a path to deprecation, but I'm saving that for
another thread.
--
nathan
Hi,
On Thu, Nov 19, 2026 at 03:58:54PM -0600, Nathan Bossart wrote:
Tar-format dumps include an undocumented restore.sql script that can be run
with psql after extracting the archive and hand-editing its $$PATH$$
placeholders. pg_restore never reads it. This script has needed a number
of fixes over the years (e.g., commits bf0945e863, ff75219e9f, 3c5d9d914f,
and 146e03e79a), and it still fails to restore table data for dumps taken
with --inserts. Furthermore, it is generated by a second pass over the
TOC, which forced tar-only hacks into the statistics code added by commits
7d5c83b4e9 and 9c02e3a986. Those hacks run all the attribute statistics
queries a second time just for this file.We could spend more time fixing restore.sql, but by all indications, it
sees minimal use, and "pg_restore -f" can generate a script from the same
archive. IIRC this file was originally added in case users did not have
access to pg_restore, but that seems like a relatively unlikely situation
these days. So, I think we should just remove it, as per the attached.Thoughts?
Thanks for the patch!
+1 for removing it. Keeping a second TOC pass and tar specific machinery for an
undocumented script does not seem worth it (especially since pg_restore -f provides
the supported way to generate a script).
Having said that, the patch LGTM.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com