summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas2018-04-11 20:39:48 +0000
committerHeikki Linnakangas2018-04-11 20:40:03 +0000
commit89c2ab34039864488b8a83c03d1b1d841adf4aaf (patch)
tree488bfa8ea00dcc44fb28cb8cb96cd0fadc5d1d0c /src
parent93e60b9494672ee49bbba8b485ef9d3c76fe3a20 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/pgstat.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 1f75e2e97d0..b4d690db963 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3220,6 +3220,7 @@ pgstat_read_current_status(void)
LocalPgBackendStatus *localtable;
LocalPgBackendStatus *localentry;
char *localappname,
+ *localclienthostname,
*localactivity;
#ifdef USE_SSL
PgBackendSSLStatus *localsslstatus;
@@ -3238,6 +3239,9 @@ pgstat_read_current_status(void)
localappname = (char *)
MemoryContextAlloc(pgStatLocalContext,
NAMEDATALEN * NumBackendStatSlots);
+ localclienthostname = (char *)
+ MemoryContextAlloc(pgStatLocalContext,
+ NAMEDATALEN * NumBackendStatSlots);
localactivity = (char *)
MemoryContextAlloc(pgStatLocalContext,
pgstat_track_activity_query_size * NumBackendStatSlots);
@@ -3278,6 +3282,8 @@ pgstat_read_current_status(void)
*/
strcpy(localappname, (char *) beentry->st_appname);
localentry->backendStatus.st_appname = localappname;
+ strcpy(localclienthostname, (char *) beentry->st_clienthostname);
+ localentry->backendStatus.st_clienthostname = localclienthostname;
strcpy(localactivity, (char *) beentry->st_activity);
localentry->backendStatus.st_activity = localactivity;
localentry->backendStatus.st_ssl = beentry->st_ssl;
@@ -3309,6 +3315,7 @@ pgstat_read_current_status(void)
localentry++;
localappname += NAMEDATALEN;
+ localclienthostname += NAMEDATALEN;
localactivity += pgstat_track_activity_query_size;
#ifdef USE_SSL
localsslstatus++;