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_state = STATE_UNDEFINED;
beentry->st_appname[0] = '\0';
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);
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
values[11] = DirectFunctionCall1(inet_in,
CStringGetDatum(remote_host));
- if (beentry->st_clienthostname)
+ if (beentry->st_clienthostname &&
+ beentry->st_clienthostname[0])
values[12] = CStringGetTextDatum(beentry->st_clienthostname);
else
nulls[12] = true;