add --transfer-mode to pg_upgrade

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: add --transfer-mode to pg_upgrade
Date: 2026-12-03 16:01:34
Message-ID: axGSXghPd_TNT5qZ@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

pg_upgrade has a separate option for each of its file transfer modes
(--clone, --copy, --copy-file-range, --link, and --swap), which I find
somewhat silly given only one mode can be used at a time. The options are
scattered around the documentation and the --help output, and every new
mode means yet another one (I'm guilty of adding the most recent). ISTM we
ought to combine them.

The attached patch adds --transfer-mode, which accepts the mode as its
argument (e.g., --transfer-mode=link). The documentation for each mode
moves to the new option, and the existing options are now listed as
deprecated spellings of it. They continue to work as before, and I doubt
we'll ever be able to remove them, but IMHO this is still an improvement.

This has come up a couple of times before. Michael suggested it while
--clone was being developed [0], and it was discussed again when --copy was
added [1] [2], but AFAICT nobody has really argued against it. It's just
always been easier to add one more option. The closest thing to an
objection I could find is Daniel's remark that multiple-choice parameters
aren't a common pattern in our utilities [3], but we've since added
--sync-method and --set-char-signedness, so I think that's less true than
it used to be. There's also precedent for this sort of change. After
pg_basebackup gained -X/--xlog-method, -x/--xlog was documented as
"equivalent of using -X with method fetch" until it was removed in v10.

In the same message, Daniel noted that we typically use a last-one-wins
strategy for options that are specified more than once, so I didn't add any
checks for conflicting options (e.g., --transfer-mode=clone overrides an
earlier --link). I also haven't touched pg_combinebackup, which has four
of the same options, but I'm happy to give it the same treatment if folks
like this.

Thoughts?

[0] https://postgr.es/m/20180928051953.GH1500%40paquier.xyz
[1] https://postgr.es/m/50a97009-8ff9-ca4d-a0f6-6086a6775a5b%40enterprisedb.com
[2] https://postgr.es/m/20221202.095650.413092142832173887.horikyota.ntt%40gmail.com
[3] https://postgr.es/m/4BB4EA0D-E818-4ECC-8041-4F46F7E63B30%40yesql.se

--
nathan

Attachment Content-Type Size
v1-0001-pg_upgrade-Add-transfer-mode.patch text/plain 15.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-12-03 16:07:50 Re: add --transfer-mode to pg_upgrade
Previous Message Corey Huinker 2026-12-03 15:47:28 Re: postgres_fdw can crash on malformed remote results