Skip to content

Commit fce7c73

Browse files
committed
Sort guc_parameters.dat alphabetically by name
The order in this list 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 using alphabetical order, the place for new entries becomes clear, and often related entries will be listed close together. This patch reorders the existing entries in guc_parameters.dat, and it also augments the generation script to error if an entry is found at the wrong place. Note: The order is actually checked after lower-casing, to handle the likes of "DateStyle". Reviewed-by: John Naylor <[email protected]> Reviewed-by: Álvaro Herrera <[email protected]> Reviewed-by: Heikki Linnakangas <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
1 parent 8f29467 commit fce7c73

File tree

2 files changed

+2469
-2459
lines changed

2 files changed

+2469
-2459
lines changed

src/backend/utils/misc/gen_guc_tables.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,21 @@ sub dquote
4242
sub print_table
4343
{
4444
my ($ofh) = @_;
45+
my $prev_name = undef;
4546

4647
print $ofh "\n\n";
4748
print $ofh "struct config_generic ConfigureNames[] =\n";
4849
print $ofh "{\n";
4950

5051
foreach my $entry (@{$parse})
5152
{
53+
if (defined($prev_name) && lc($prev_name) ge lc($entry->{name}))
54+
{
55+
die sprintf(
56+
"entries are not in alphabetical order: \"%s\", \"%s\"\n",
57+
$prev_name, $entry->{name});
58+
}
59+
5260
print $ofh "#ifdef $entry->{ifdef}\n" if $entry->{ifdef};
5361
print $ofh "\t{\n";
5462
printf $ofh "\t\t.name = %s,\n", dquote($entry->{name});
@@ -80,6 +88,8 @@ sub print_table
8088
print $ofh "\t},\n";
8189
print $ofh "#endif\n" if $entry->{ifdef};
8290
print $ofh "\n";
91+
92+
$prev_name = $entry->{name};
8393
}
8494

8595
print $ofh "\t/* End-of-list marker */\n";

0 commit comments

Comments
 (0)