Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit682c5bb

Browse files
committed
Fix bugs in manipulation of PgBackendStatus.st_clienthostname.
Initialization of this field was not being done according to thest_changecount protocol (it has to be done within the changecount incrementrange, not outside). And the test to see if the value should be reportedas null was wrong. Noted while perusing uses of Port.remote_hostname.This was wrong from the introduction of this code (commit4a25bc1),so back-patch to 9.1.
1 parent8bbbcb9 commit682c5bb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,11 @@ pgstat_bestart(void)
25812581
beentry->st_databaseid=MyDatabaseId;
25822582
beentry->st_userid=userid;
25832583
beentry->st_clientaddr=clientaddr;
2584-
beentry->st_clienthostname[0]='\0';
2584+
if (MyProcPort&&MyProcPort->remote_hostname)
2585+
strlcpy(beentry->st_clienthostname,MyProcPort->remote_hostname,
2586+
NAMEDATALEN);
2587+
else
2588+
beentry->st_clienthostname[0]='\0';
25852589
beentry->st_waiting= false;
25862590
beentry->st_state=STATE_UNDEFINED;
25872591
beentry->st_appname[0]='\0';
@@ -2594,9 +2598,6 @@ pgstat_bestart(void)
25942598
beentry->st_changecount++;
25952599
Assert((beentry->st_changecount&1)==0);
25962600

2597-
if (MyProcPort&&MyProcPort->remote_hostname)
2598-
strlcpy(beentry->st_clienthostname,MyProcPort->remote_hostname,NAMEDATALEN);
2599-
26002601
/* Update app name to current GUC setting */
26012602
if (application_name)
26022603
pgstat_report_appname(application_name);

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
760760
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family,remote_host);
761761
values[11]=DirectFunctionCall1(inet_in,
762762
CStringGetDatum(remote_host));
763-
if (beentry->st_clienthostname)
763+
if (beentry->st_clienthostname&&
764+
beentry->st_clienthostname[0])
764765
values[12]=CStringGetTextDatum(beentry->st_clienthostname);
765766
else
766767
nulls[12]= true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp