aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/pgstat.c9
-rw-r--r--src/backend/utils/adt/pgstatfuncs.c3
2 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 77e195e554d..e1e60294ea0 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -2404,7 +2404,11 @@ pgstat_bestart(void)
beentry->st_databaseid = MyDatabaseId;
beentry->st_userid = userid;
beentry->st_clientaddr = clientaddr;
- beentry->st_clienthostname[0] = '\0';
+ if (MyProcPort && MyProcPort->remote_hostname)
+ strlcpy(beentry->st_clienthostname, MyProcPort->remote_hostname,
+ NAMEDATALEN);
+ else
+ beentry->st_clienthostname[0] = '\0';
beentry->st_waiting = false;
beentry->st_appname[0] = '\0';
beentry->st_activity[0] = '\0';
@@ -2416,9 +2420,6 @@ pgstat_bestart(void)
beentry->st_changecount++;
Assert((beentry->st_changecount & 1) == 0);
- if (MyProcPort && MyProcPort->remote_hostname)
- strlcpy(beentry->st_clienthostname, MyProcPort->remote_hostname, NAMEDATALEN);
-
/* Update app name to current GUC setting */
if (application_name)
pgstat_report_appname(application_name);
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index c75b9420264..e0ec08e4b47 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -694,7 +694,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
values[9] = DirectFunctionCall1(inet_in,
CStringGetDatum(remote_host));
- if (beentry->st_clienthostname)
+ if (beentry->st_clienthostname &&
+ beentry->st_clienthostname[0])
values[10] = CStringGetTextDatum(beentry->st_clienthostname);
else
nulls[10] = true;