Reorganize GUC structs
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-10-03T06:55:10Z
Lists: pgsql-hackers
Attachments
- v1-0001-Modernize-some-for-loops.patch (text/plain) patch v1-0001
- v1-0002-Add-some-const-qualifiers.patch (text/plain) patch v1-0002
- v1-0003-Change-reset_extra-into-a-config_generic-common-f.patch (text/plain) patch v1-0003
- v1-0004-Use-designated-initializers-for-guc_tables.patch (text/plain) patch v1-0004
- v1-0005-Change-config_generic.vartype-to-be-initialized-a.patch (text/plain) patch v1-0005
- v1-0006-Reorganize-GUC-structs.patch (text/plain) patch v1-0006
- v1-0007-Sort-guc_parameters.dat-alphabetically-by-name.patch (text/plain) patch v1-0007
- v1-0008-Enforce-alphabetical-order-in-guc_parameters.dat.patch (text/plain) patch v1-0008
This patch series does some reorganizing of the GUC table structs (config_generic, config_bool, etc.) to modernize and simplify things. I suspect that some changes like these would have been desirable as the GUC code has evolved over time, but were avoided because of the burden of having to adjust all the static GUC tables at the same time. Since these are now generated, this is no longer a problem. The main change is that instead of having five separate structs, one for each type, with the generic part contained in each of them, flip it around and have one common struct, with the type-specific part has a subfield. The very original GUC design had type-specific structs and type-specific lists, and the membership in one of the lists defined the type. But now the structs themselves know the type (from the .vartype field), and they are all loaded into a common hash table at run time, this original separation no longer makes sense. It creates a bunch of inconsistencies in the code about whether the type-specific or the generic struct is the primary struct, and a lot of casting in between, which makes certain assumptions about the struct layouts. After the change, all these casts are gone and all the data is accessed via normal field references. Also, various code is simplified because only one kind of struct needs to be processed. Additionally, I have sorted guc_parameters.dat alphabetically by name, and have added code to enforce the sort order going forward. (Note: The order is actually checked after lower-casing, to handle the likes of "DateStyle".) The order in these lists was previously pretty random and had grown organically over time. This made it unnecessarily cumbersome to maintain these lists, as there was no clear guidelines about where to put new entries. Also, after the merger of the type-specific GUC structs, the list still reflected the previous type-specific super-order. By enforcing alphabetical order, the place for new entries becomes clear, and often related entries will be listed close together. The patches in the series are arranged so that they can be considered and applied incrementally.
Commits
-
Remove extraneous newlines from guc_parameters.dat
- a7f59b252a8e 19 (unreleased) landed
-
Fix NLS for incorrect GUC enum value hint message
- 0fc33b00536c 19 (unreleased) landed
-
Clean up qsort comparison function for GUC entries
- d2f24df19b7a 19 (unreleased) landed
-
Sort guc_parameters.dat alphabetically by name
- fce7c73fba4e 19 (unreleased) landed
-
Reorganize GUC structs
- a13833c35f9e 19 (unreleased) landed
-
Change config_generic.vartype to be initialized at compile time
- e1a912c86d52 19 (unreleased) landed
-
Use designated initializers for guc_tables
- 0a7bde461016 19 (unreleased) landed
-
Change reset_extra into a config_generic common field
- 5f4c3b33a976 19 (unreleased) landed
-
Add some const qualifiers
- 29dc7a668753 19 (unreleased) landed
-
Modernize some for loops
- 1a795188889c 19 (unreleased) landed