aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-05-15 19:55:56 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-05-15 19:55:56 -0400
commit14a91010912632cae322b06fce0425faedcf7353 (patch)
tree49bbf3e514ac1a3ed4c66a15f415fd6b8290d1af /src
parent8048404939bb0fcef80b0ab57910b6e10d4289a3 (diff)
downloadpostgresql-14a91010912632cae322b06fce0425faedcf7353.tar.gz
postgresql-14a91010912632cae322b06fce0425faedcf7353.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/lmgr/generate-lwlocknames.pl8
-rw-r--r--src/backend/storage/lmgr/lwlock.c5
-rw-r--r--src/include/storage/lwlock.h1
3 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl
index 50fb8625cad..ca54acdfb0f 100644
--- a/src/backend/storage/lmgr/generate-lwlocknames.pl
+++ b/src/backend/storage/lmgr/generate-lwlocknames.pl
@@ -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";
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c
index 0bdc8e0499d..2fa90cc0954 100644
--- a/src/backend/storage/lmgr/lwlock.c
+++ b/src/backend/storage/lmgr/lwlock.c
@@ -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)
diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h
index d8e1b5c493e..c04ae971485 100644
--- a/src/include/storage/lwlock.h
+++ b/src/include/storage/lwlock.h
@@ -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