mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Unify several ways to tracking backend type
Add a new global variable MyBackendType that uses the same BackendType enum that was previously only used by the stats collector. That way several duplicate ways of checking what type a particular process is can be simplified. Since it's no longer just for stats, move to miscinit.c and rename existing functions to match the expanded purpose. Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Kuntal Ghosh <kuntalghosh.2007@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/c65e5196-4f04-4ead-9353-6088c19615a3@2ndquadrant.com
This commit is contained in:
@@ -2259,6 +2259,11 @@ retry1:
|
||||
if (strlen(port->user_name) >= NAMEDATALEN)
|
||||
port->user_name[NAMEDATALEN - 1] = '\0';
|
||||
|
||||
if (am_walsender)
|
||||
MyBackendType = B_WAL_SENDER;
|
||||
else
|
||||
MyBackendType = B_BACKEND;
|
||||
|
||||
/*
|
||||
* Normal walsender backends, e.g. for streaming replication, are not
|
||||
* connected to a particular database. But walsenders used for logical
|
||||
@@ -4422,7 +4427,7 @@ BackendInitialize(Port *port)
|
||||
*/
|
||||
initStringInfo(&ps_data);
|
||||
if (am_walsender)
|
||||
appendStringInfo(&ps_data, "%s ", pgstat_get_backend_desc(B_WAL_SENDER));
|
||||
appendStringInfo(&ps_data, "%s ", GetBackendTypeDesc(B_WAL_SENDER));
|
||||
appendStringInfo(&ps_data, "%s ", port->user_name);
|
||||
if (!am_walsender)
|
||||
appendStringInfo(&ps_data, "%s ", port->database_name);
|
||||
|
||||
Reference in New Issue
Block a user