mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
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
This commit is contained in:
@ -2786,6 +2786,7 @@ pgstat_read_current_status(void)
|
|||||||
PgBackendStatus *localtable;
|
PgBackendStatus *localtable;
|
||||||
PgBackendStatus *localentry;
|
PgBackendStatus *localentry;
|
||||||
char *localappname,
|
char *localappname,
|
||||||
|
*localclienthostname,
|
||||||
*localactivity;
|
*localactivity;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -2801,6 +2802,9 @@ pgstat_read_current_status(void)
|
|||||||
localappname = (char *)
|
localappname = (char *)
|
||||||
MemoryContextAlloc(pgStatLocalContext,
|
MemoryContextAlloc(pgStatLocalContext,
|
||||||
NAMEDATALEN * MaxBackends);
|
NAMEDATALEN * MaxBackends);
|
||||||
|
localclienthostname = (char *)
|
||||||
|
MemoryContextAlloc(pgStatLocalContext,
|
||||||
|
NAMEDATALEN * MaxBackends);
|
||||||
localactivity = (char *)
|
localactivity = (char *)
|
||||||
MemoryContextAlloc(pgStatLocalContext,
|
MemoryContextAlloc(pgStatLocalContext,
|
||||||
pgstat_track_activity_query_size * MaxBackends);
|
pgstat_track_activity_query_size * MaxBackends);
|
||||||
@ -2832,6 +2836,8 @@ pgstat_read_current_status(void)
|
|||||||
*/
|
*/
|
||||||
strcpy(localappname, (char *) beentry->st_appname);
|
strcpy(localappname, (char *) beentry->st_appname);
|
||||||
localentry->st_appname = localappname;
|
localentry->st_appname = localappname;
|
||||||
|
strcpy(localclienthostname, (char *) beentry->st_clienthostname);
|
||||||
|
localentry->st_clienthostname = localclienthostname;
|
||||||
strcpy(localactivity, (char *) beentry->st_activity);
|
strcpy(localactivity, (char *) beentry->st_activity);
|
||||||
localentry->st_activity = localactivity;
|
localentry->st_activity = localactivity;
|
||||||
}
|
}
|
||||||
@ -2850,6 +2856,7 @@ pgstat_read_current_status(void)
|
|||||||
{
|
{
|
||||||
localentry++;
|
localentry++;
|
||||||
localappname += NAMEDATALEN;
|
localappname += NAMEDATALEN;
|
||||||
|
localclienthostname += NAMEDATALEN;
|
||||||
localactivity += pgstat_track_activity_query_size;
|
localactivity += pgstat_track_activity_query_size;
|
||||||
localNumBackends++;
|
localNumBackends++;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user