Skip to content

Commit 89c2ab3

Browse files
committed
Make local copy of client hostnames in backend status array.
The other strings, application_name and query string, were snapshotted to local memory in pgstat_read_current_status(), but we forgot to do that for client hostnames. As a result, the client hostname would appear to change in the local copy, if the client disconnected. Backpatch to all supported versions. Author: Edmund Horner Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/CAMyN-kA7aOJzBmrYFdXcc7Z0NmW%2B5jBaf_m%3D_-77uRNyKC9r%3DA%40mail.gmail.com
1 parent 93e60b9 commit 89c2ab3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,6 +3220,7 @@ pgstat_read_current_status(void)
32203220
LocalPgBackendStatus *localtable;
32213221
LocalPgBackendStatus *localentry;
32223222
char *localappname,
3223+
*localclienthostname,
32233224
*localactivity;
32243225
#ifdef USE_SSL
32253226
PgBackendSSLStatus *localsslstatus;
@@ -3238,6 +3239,9 @@ pgstat_read_current_status(void)
32383239
localappname = (char *)
32393240
MemoryContextAlloc(pgStatLocalContext,
32403241
NAMEDATALEN * NumBackendStatSlots);
3242+
localclienthostname = (char *)
3243+
MemoryContextAlloc(pgStatLocalContext,
3244+
NAMEDATALEN * NumBackendStatSlots);
32413245
localactivity = (char *)
32423246
MemoryContextAlloc(pgStatLocalContext,
32433247
pgstat_track_activity_query_size * NumBackendStatSlots);
@@ -3278,6 +3282,8 @@ pgstat_read_current_status(void)
32783282
*/
32793283
strcpy(localappname, (char *) beentry->st_appname);
32803284
localentry->backendStatus.st_appname = localappname;
3285+
strcpy(localclienthostname, (char *) beentry->st_clienthostname);
3286+
localentry->backendStatus.st_clienthostname = localclienthostname;
32813287
strcpy(localactivity, (char *) beentry->st_activity);
32823288
localentry->backendStatus.st_activity = localactivity;
32833289
localentry->backendStatus.st_ssl = beentry->st_ssl;
@@ -3309,6 +3315,7 @@ pgstat_read_current_status(void)
33093315

33103316
localentry++;
33113317
localappname += NAMEDATALEN;
3318+
localclienthostname += NAMEDATALEN;
33123319
localactivity += pgstat_track_activity_query_size;
33133320
#ifdef USE_SSL
33143321
localsslstatus++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy