A function reporting a backend's client port

pg_stat_get_backend_client_port() is a system function 

pg_stat_get_backend_client_port() was added in PostgreSQL 8.1.


pg_stat_get_backend_client_port ( integer ) → integer

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_port() corresponds to the column client_port in pg_stat_activity.

To obtain the client port of the current backend, use inet_client_port().

The following related functions are also available:

Change history


Basic usage example for pg_stat_get_backend_client_port():

postgres=# SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
                  pg_stat_get_backend_client_port(s.backendid) AS client_port
             FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;
   pid   | client_port 
 1451980 |            
 1451982 |            
 2089310 |       57760
 1764534 |       34674
 1451978 |            
 1451977 |            
 1451979 |            
(7 rows)


System function

See also

pg_stat_activity, inet_client_port()