1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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
This commit is contained in:
Tom Lane
2020-05-15 19:55:56 -04:00
parent 8048404939
commit 14a9101091
4 changed files with 53 additions and 49 deletions

View File

@ -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";

View File

@ -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)

View File

@ -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