pg_stat_get_backend_client_addr()
A function reporting a backend's client address
pg_stat_get_backend_client_addr()
is a system function reporting the client address of the user connected to the specified backend.
pg_stat_get_backend_client_addr()
was added in PostgreSQL 8.1.
Usage
pg_stat_get_backend_client_addr (integer
) →inet
The backend is specified by a backend ID number reported by pg_stat_get_backend_idset()
; see below for an execution example.
The value returned by pg_stat_get_backend_client_addr()
corresponds to the column client_addr
in pg_stat_activity
.
To obtain the client address of the current backend, use inet_client_addr()
.
Related functions
The following related functions are also available:
pg_stat_get_backend_activity()
pg_stat_get_backend_activity_start()
pg_stat_get_backend_client_port()
pg_stat_get_backend_dbid()
pg_stat_get_backend_pid()
pg_stat_get_backend_start()
pg_stat_get_backend_userid()
pg_stat_get_backend_wait_event()
pg_stat_get_backend_wait_event_type()
pg_stat_get_backend_xact_start()
Change history
- PostgreSQL 8.1
- added (commit 4744c1a0)
Examples
Basic usage example for pg_stat_get_backend_client_addr()
:
postgres=# SELECT pg_stat_get_backend_pid(s.backendid) AS pid, pg_stat_get_backend_client_addr(s.backendid) AS client_addr FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; pid | client_addr ---------+------------- 1451980 | 1451982 | 2081074 | 127.0.0.1 1764534 | 127.0.0.1 1451978 | 1451977 | 1451979 | (7 rows)
References
- PostgreSQL documentation: Per-Backend Statistics Functions