Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 59cbf60

Browse files
committed
Remove column for wait event names in wait_event_names.txt
This file is now made of two columns, removing the column listing the user-visible strings used in the system views and the documentation: - Enum definitions for each class without the prefix "WAIT_EVENT_", so as this information can be grepped in the code and wait_event_names.txt at the same time. - Description in the documentation. The wait event names are now generated from the enum objects in CamelCase, with the underscores removed. The data generated for wait events is consistent with what was produced by 414f6c0. This has the advantage to remove WAIT_EVENT_DOCONLY, which was a placeholder for the wait event types Lock and LWLock as these two only require the generation of the documentation. Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/ZOxVHQwEC/9X/p/z@paquier.xyz
1 parent 414f6c0 commit 59cbf60

File tree

2 files changed

+279
-263
lines changed

2 files changed

+279
-263
lines changed

src/backend/utils/activity/generate-wait_event_types.pl

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,45 @@
6565
push(@lines, $section_name . "\t" . $_);
6666
}
6767

68-
# Sort the lines based on the third column.
68+
# Sort the lines based on the second column.
6969
# uc() is being used to force the comparison to be case-insensitive.
7070
my @lines_sorted =
71-
sort { uc((split(/\t/, $a))[2]) cmp uc((split(/\t/, $b))[2]) } @lines;
71+
sort { uc((split(/\t/, $a))[1]) cmp uc((split(/\t/, $b))[1]) } @lines;
7272

7373
# Read the sorted lines and populate the hash table
7474
foreach my $line (@lines_sorted)
7575
{
7676
die "unable to parse wait_event_names.txt for line $line\n"
77-
unless $line =~ /^(\w+)\t+(\w+)\t+(\w+)\t+("\w.*\.")$/;
77+
unless $line =~ /^(\w+)\t+(\w+)\t+("\w.*\.")$/;
7878

79-
( my $waitclassname,
80-
my $waiteventenumname,
81-
my $waiteventdescription,
82-
my $waitevendocsentence) = split(/\t/, $line);
79+
(my $waitclassname, my $waiteventname, my $waitevendocsentence) =
80+
split(/\t/, $line);
8381

82+
# Generate the element name for the enums based on the
83+
# description. The C symbols are prefixed with "WAIT_EVENT_".
84+
my $waiteventenumname = "WAIT_EVENT_$waiteventname";
85+
86+
# Build the descriptions. These are in camel-case.
87+
# LWLock and Lock classes do not need any modifications.
88+
my $waiteventdescription = '';
89+
if ( $waitclassname eq 'WaitEventLWLock'
90+
|| $waitclassname eq 'WaitEventLock')
91+
{
92+
$waiteventdescription = $waiteventname;
93+
}
94+
else
95+
{
96+
my @waiteventparts = split("_", $waiteventname);
97+
foreach my $waiteventpart (@waiteventparts)
98+
{
99+
$waiteventdescription .= substr($waiteventpart, 0, 1)
100+
. lc(substr($waiteventpart, 1, length($waiteventpart)));
101+
}
102+
}
103+
104+
# Store the event into the list for each class.
84105
my @waiteventlist =
85106
[ $waiteventenumname, $waiteventdescription, $waitevendocsentence ];
86-
my $trimmedwaiteventname = $waiteventenumname;
87-
$trimmedwaiteventname =~ s/^WAIT_EVENT_//;
88-
89-
die "wait event names must start with 'WAIT_EVENT_'"
90-
if ($trimmedwaiteventname eq $waiteventenumname);
91107
push(@{ $hashwe{$waitclassname} }, @waiteventlist);
92108
}
93109

0 commit comments

Comments
 (0)