Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com>
Cc: Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] pg_upgrade: add --initdb option to create the new cluster automatically
Date: 2026-08-12 15:42:57
Message-ID: 23C10B41-AA5E-4F3F-9727-CA94F9B84817@yesql.se
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 17 Jul 2026, at 14:10, Bohyun Lee <bohyun(dot)lee(at)databricks(dot)com> wrote:

> • Reworked the manual-initdb docs: the vague "use compatible initdb flags" is now the specific settings that must match (WAL segment size, checksums, encoding, locale), with a pointer to pg_controldata.

Regardless of the rest of the patch, I think we should apply something like
this to the docs. I propose you extract this portion into a separate 0001 in
this patchset so that it can be considered individually.

I haven't had a chance to look at the new version more than at skim-level but
the below caught my eye.

+ initPQExpBuffer(&cmd);
+ appendPQExpBuffer(&cmd, "\"%s/initdb\" -D \"%s\" -N",
+ new_cluster.bindir, new_cluster.pgdata);
+ appendPQExpBuffer(&cmd, " -U \"%s\"", os_info.user);

This will inject the username specified in the (untrusted input) commandline
into the initdb command and execute it. While that will work in benign cases,
it seems like a Booby Tables pattern which is best left in the coding practices
of the past and in XKCD?

--
Daniel Gustafsson

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2026-08-12 15:43:07 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Sami Imseih 2026-08-12 15:34:51 Disallow outer-level and WHERE-clause aggregates in GRAPH_TABLE