From 1da67d974261b855ce1f10e1f9aecda06b57a09e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 3 Oct 2025 08:27:18 +0200 Subject: [PATCH v1 8/8] Enforce alphabetical order in guc_parameters.dat 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. Note: The order is actually checked after lower-casing, to handle the likes of "DateStyle". --- src/backend/utils/misc/gen_guc_tables.pl | 8 ++++++++ src/backend/utils/misc/guc_parameters.dat | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/misc/gen_guc_tables.pl b/src/backend/utils/misc/gen_guc_tables.pl index 0823e2e552c..05d1daea56b 100644 --- a/src/backend/utils/misc/gen_guc_tables.pl +++ b/src/backend/utils/misc/gen_guc_tables.pl @@ -42,6 +42,7 @@ sub dquote sub print_table { my ($ofh) = @_; + my $prev_name = undef; print $ofh "\n\n"; print $ofh "struct config_generic ConfigureNames[] =\n"; @@ -49,6 +50,11 @@ sub print_table foreach my $entry (@{$parse}) { + if (defined($prev_name) && lc($prev_name) ge lc($entry->{name})) + { + die sprintf("entries are not in alphabetical order: \"%s\", \"%s\"\n", $prev_name, $entry->{name}); + } + print $ofh "#ifdef $entry->{ifdef}\n" if $entry->{ifdef}; print $ofh "\t{\n"; printf $ofh "\t\t.name = %s,\n", dquote($entry->{name}); @@ -71,6 +77,8 @@ sub print_table print $ofh "\t},\n"; print $ofh "#endif\n" if $entry->{ifdef}; print $ofh "\n"; + + $prev_name = $entry->{name}; } print $ofh "\t/* End-of-list marker */\n"; diff --git a/src/backend/utils/misc/guc_parameters.dat b/src/backend/utils/misc/guc_parameters.dat index d54c65ee9c3..dffcde73e92 100644 --- a/src/backend/utils/misc/guc_parameters.dat +++ b/src/backend/utils/misc/guc_parameters.dat @@ -23,7 +23,7 @@ # 3. Decide on a name, a default value, upper and lower bounds (if # applicable), etc. # -# 4. Add a record below. +# 4. Add a record below (in alphabetical order). # # 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if # appropriate. -- 2.51.0