Commit 14a91010 authored by Tom Lane's avatar Tom Lane

Drop the redundant "Lock" suffix from LWLock wait event names.

This was mostly confusing, especially since some wait events in
this class had the suffix and some did not.

While at it, stop exposing MainLWLockNames[] as a globally visible
name; any code using that directly is almost certainly wrong, as
its name has been misleading for some time.
(GetLWLockIdentifier() is what to use instead.)

Discussion: https://postgr.es/m/28683.1589405363@sss.pgh.pa.us
parent 80484049
This diff is collapsed.
......@@ -23,7 +23,7 @@ print $h $autogen;
print $h "/* there is deliberately not an #ifndef LWLOCKNAMES_H here */\n\n";
print $c $autogen, "\n";
print $c "const char *const MainLWLockNames[] = {";
print $c "const char *const IndividualLWLockNames[] = {";
while (<$lwlocknames>)
{
......@@ -38,6 +38,10 @@ while (<$lwlocknames>)
(my $lockname, my $lockidx) = ($1, $2);
my $trimmedlockname = $lockname;
$trimmedlockname =~ s/Lock$//;
die "lock names must end with 'Lock'" if $trimmedlockname eq $lockname;
die "lwlocknames.txt not in order" if $lockidx < $lastlockidx;
die "lwlocknames.txt has duplicates" if $lockidx == $lastlockidx;
......@@ -47,7 +51,7 @@ while (<$lwlocknames>)
printf $c "%s \"<unassigned:%d>\"", $continue, $lastlockidx;
$continue = ",\n";
}
printf $c "%s \"%s\"", $continue, $lockname;
printf $c "%s \"%s\"", $continue, $trimmedlockname;
$lastlockidx = $lockidx;
$continue = ",\n";
......
......@@ -111,7 +111,7 @@ extern slock_t *ShmemLock;
* There are three sorts of LWLock "tranches":
*
* 1. The individually-named locks defined in lwlocknames.h each have their
* own tranche. The names of these tranches appear in MainLWLockNames[]
* own tranche. The names of these tranches appear in IndividualLWLockNames[]
* in lwlocknames.c.
*
* 2. There are some predefined tranches for built-in groups of locks.
......@@ -125,6 +125,7 @@ extern slock_t *ShmemLock;
* All these names are user-visible as wait event names, so choose with care
* ... and do not forget to update the documentation's list of wait events.
*/
extern const char *const IndividualLWLockNames[]; /* in lwlocknames.c */
static const char *const BuiltinTrancheNames[] = {
/* LWTRANCHE_XACT_BUFFER: */
......@@ -781,7 +782,7 @@ GetLWTrancheName(uint16 trancheId)
{
/* Individual LWLock? */
if (trancheId < NUM_INDIVIDUAL_LWLOCKS)
return MainLWLockNames[trancheId];
return IndividualLWLockNames[trancheId];
/* Built-in tranche? */
if (trancheId < LWTRANCHE_FIRST_USER_DEFINED)
......
......@@ -88,7 +88,6 @@ typedef union LWLockMinimallyPadded
} LWLockMinimallyPadded;
extern PGDLLIMPORT LWLockPadded *MainLWLockArray;
extern const char *const MainLWLockNames[];
/* struct for storing named tranche information */
typedef struct NamedLWLockTranche
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment