Re: Generate GUC tables from .dat file - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Generate GUC tables from .dat file
Date
Msg-id c9affeb9-7779-406a-8562-2ba4777cd3b7@eisentraut.org
Whole thread Raw
In response to Generate GUC tables from .dat file  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Generate GUC tables from .dat file
List 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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: VM corruption on standby
Next
From: Tom Lane
Date:
Subject: Re: Improve LWLock tranche name visibility across backends