Re: Generate GUC tables from .dat file

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Generate GUC tables from .dat file
Date: 2025-08-19 20:18:30
Message-ID: c9affeb9-7779-406a-8562-2ba4777cd3b7@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11.08.25 08:04, Peter Eisentraut wrote:
> So here is an initial POC patch.  I have written a script to convert a
> new src/backend/utils/misc/guc_parameters.dat to what would be
> guc_tables.c, but in the patch it's guc_tables_new.c.  The
> guc_parameters.dat in the patch is populated only with a few entries
> that cover most of the different types and variants and possible
> settings, so we can see what it would look like.  Eventually, this would
> require a big conversion.
>
> My next goal would be to make this work so that most of guc_tables.c is
> generated, and nothing else changes beyond that.

Ok, I did the big conversion, and tidied everything up so that it now
generates the big tables in guc_tables.c from the .dat file. This
basically works now.

Some notes:

- I included a preparatory patch to clean up some formatting in
guc_tables.c so that it's easier to visually compare the generated code.

- Similarly, for this time, I left the order of the entries in
guc_parameters.dat to be the same as it was in guc_tables.c, so that
it's easier to compare. Eventually I would like to re-order those,
probably alphabetically, but that can be a separate follow-up patch.

- In this patch, I left the code to be replaced in guc_tables.c, so that
it's easier to keep this patch rebased. But you should imagine that the
parts under NOT_USED will get deleted.

- One thing I didn't reproduce in the generated code is the line breaks
in the description strings. But that should be ok either way.

- In a few places there were complicated #ifdef's to determine the
default value. I extracted that out into separate symbols.

- Eventually it would be interesting to try to generate the other parts
of guc_tables.c, like the enums and the categories, but I'm leaving that
for another time.

- I moved the C code comments into the .dat file as Perl comments. I
figure that makes sense as that's where people would be editing now.

I feel that if people like this format, this is functional and useful as
a first step.

Attachment Content-Type Size
v1-0001-Formatting-cleanup-of-guc_tables.c.patch text/plain 39.2 KB
v1-0002-Generate-GUC-tables-from-.dat-file.patch text/plain 153.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-08-19 20:26:41 Re: Improve LWLock tranche name visibility across backends
Previous Message Tom Lane 2025-08-19 19:55:41 Re: VM corruption on standby