My idea is to store the information in guc_tables.c in a .dat file
similar to the catalog data in src/include/catalog/, and generated
guc_tables.c from that. I want to make it easier to edit that
information, and I want to be able to make changes to the downstream
data structures more easily. (Essentially, those are the same reasons
as for the original adoption of the .dat format.)
An important project is to adapt the GUC system to a multithreaded
server. The leading idea is to convert most global variables to
thread-local storage. But this doesn't work with the current global
structs, because they can't contain a pointer to a thread-local
variable. Some workarounds and changes exist in WIP threading branches,
but they all require at least some mechanical changes to the global
tables. If these tables could be generated automatically, it would be
easier to try out different things.
More generally, maybe the current format of a global struct that points
to many global variables is not the right one anymore. Maybe the global
variables should be packaged into a struct, or several structs. Or
maybe the whole thing could just be a hash table and you retrieve values
when you need them. Who knows. But this would make it easier to
experiment and make changes.
Another possible benefit would be that we could generate the
postgresql.conf.sample file. This is also very tedious to edit and
maintain, and sometimes people want to make larger changes, and this is
very difficult. And then we might not need tests like 003_check_guc.pl
that check the consistency of the sample file.
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. But before I do all
the remaining tedious work, I wanted to check what people think.