Set arbitrary GUC options during initdb

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Set arbitrary GUC options during initdb
Date: 2023-01-25 21:25:19
Message-ID: 2844176.1674681919@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The attached patch responds to the discussion at [1] about how
we ought to offer a way to set any server GUC from the initdb
command line. Currently, if for some reason the server won't
start with default parameters, the only way to get through initdb
is to change the installed version of postgresql.conf.sample.
And even that is just a kluge, because the initial probes to
choose max_connections and shared_buffers will all fail, causing
initdb to choose rock-bottom-minimum values of those settings.
You can fix that up after the fact if you notice it, but you
might not.

So this invents an initdb switch "-c NAME=VALUE" just like the
one that the server itself has long had. The specified settings
are applied on the command line of the initial probe calls
(which happen before we've made any config files), and then they
are added to postgresql.auto.conf, which causes them to take
effect for the bootstrap backend runs as well as subsequent
postmaster starts.

I also invented "--set NAME=VALUE", mainly because just about
every other initdb switch has a long form. The server itself
doesn't have that spelling, so I'm not wedded to that part.

Thoughts?

regards, tom lane

[1] https://www.postgresql.org/message-id/flat/17757-dbdfc1f1c954a6db%40postgresql.org

Attachment Content-Type Size
set-arbitrary-options-during-initdb-1.patch text/x-diff 10.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-01-25 21:26:49 Re: plpython vs _POSIX_C_SOURCE
Previous Message Jeff Davis 2023-01-25 21:16:44 Re: GUCs to control abbreviated sort keys