8000 Make local copy of client hostnames in backend status array. · tomdcc/postgres@dfc383c · GitHub
[go: up one dir, main page]

Skip to content

Commit dfc383c

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 bd213fd commit dfc383c

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
@@ -2786,6 +2786,7 @@ pgstat_read_current_status(void)
27862786
PgBackendStatus *localtable;
27872787
PgBackendStatus *localentry;
27882788
char *localappname,
2789+
*localclienthostname,
27892790
*localactivity;
27902791
int i;
27912792

@@ -2801,6 +2802,9 @@ pgstat_read_current_status(void)
28012802
localappname = (char *)
28022803
MemoryContextAlloc(pgStatLocalContext,
28032804
NAMEDATALEN * MaxBackends);
2805+
localclienthostname = (char *)
2806+
MemoryContextAlloc(pgStatLocalContext,
2807+
NAMEDATALEN * MaxBackends);
28042808
localactivity = (char *)
28052809
MemoryContextAlloc(pgStatLocalContext,
28062810
pgstat_track_activity_query_size * MaxBackends);
@@ -2832,6 +2836,8 @@ pgstat_read_current_status(void)
28322836
*/
28332837
strcpy(localappname, (char *) beentry->st_appname);
28342838
localentry->st_appname = localappname;
2839+
strcpy(localclienthostname, (char *) beentry->st_clienthostname);
2840+
localentry->st_clienthostname = localclienthostname;
28352841
strcpy(localactivity, (char *) beentry->st_activity);
28362842
localentry->st_activity = localactivity;
28372843
}
@@ -2850,6 +2856,7 @@ pgstat_read_current_status(void)
28502856
{
28512857
localentry++;
28522858
localappname += NAMEDATALEN;
2859+
localclienthostname += NAMEDATALEN;
28532860
localactivity += pgstat_track_activity_query_size;
28542861
localNumBackends++;
28552862
}

0 commit comments

Comments
 (0)
0