Hi Heikki, Daniel, and Greg, As Heikki suggested, I've started with --print-initdb-options because Debian's pg_upgradecluster needs it. Indeed, it would be nice to better support users of Debian’s upgrade scripts, as well as those running pg_upgrade directly.
The attached v11 patch adds:
pg_upgrade --print-initdb-options -b /old/bin -d /old/data
It prints one line of shell-quoted initdb arguments, following
pg_config --configure, with diagnostics on stderr, including the WAL
segment size, checksum setting, and template0 encoding and locale
defaults.
Printing can inspect a running or stopped source. It does not check a
target cluster, so combining it with --check is rejected. After creating
the target, callers can run ordinary pg_upgrade --check.
I've also attached a postgresql-common companion patch demonstrating how
pg_upgradecluster can use the printed WAL/checksum settings while
retaining Debian's maintenance-database selection, locale overrides,
configuration copying, and hooks.
This preserves the opportunity to set shared_preload_libraries before the
new server starts. The PG TAP test covers output reuse through a
normal check and upgrade, shell quoting, and source lifecycle. I also
tested the patched pg_upgradecluster through a complete upgrade in an
isolated Debian package layout.
Best,
Bohyun
On Wed, Nov 25, 2026 at 4:12 PM Greg Sabino Mullane <[email protected]>
wrote:
> On Fri, Nov 20, 2026 at 8:11 AM Heikki Linnakangas <[email protected]>
> wrote:
>
>> Setting shared_preload_libraries in the config file.
>
>
> Thanks, that's a good example. While some don't require it and CREATE
> EXTENSION works fine (e.g. the one I immediately thought of,
> pg_stat_statements), others do require a middle step (e.g. pg_cron). Your
> --print-initdb-options and --initdb-only ideas are good, and I lean towards
> the latter. The other option is to make --initdb smarter. Maybe that means
> copying the existing conf files over, maybe it means picking pieces out
> like shared_preload_libraries. At any rate, that's probably a bigger ask
> than this patch. Perhaps we can just release this patch as is (with a
> --initdb flag), and have a separate patch that does --initdb-only and/or
> gives --initdb more brains?
>
> Cheers,
> Greg
>
>
v1-postgresql-common-initdb-options.patch
Description: Binary data
v11-pg_upgrade-print-initdb-options.patch
Description: Binary data
