pg_stat_get_backend_userid()
A function reporting a backend's user OID
pg_stat_get_backend_userid()
is a system function reporting the OID of the user accessing the specified backend.
pg_stat_get_backend_userid()
was added in PostgreSQL 7.2.
Usage
pg_stat_get_backend_userid (integer
) →oid
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_activity_start()
corresponds to the column usesysid
in pg_stat_activity
.
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_addr()
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_wait_event()
pg_stat_get_backend_wait_event_type()
pg_stat_get_backend_xact_start()
Change history
- PostgreSQL 7.2
- added (commit 140ddb78)
Examples
Basic usage example for pg_stat_get_backend_userid()
:
postgres=# SELECT pg_stat_get_backend_pid(s.backendid) AS pid, pg_stat_get_backend_userid(s.backendid) AS usesysid FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s; pid | usesysid ---------+---------- 1451980 | 0 1451982 | 10 2078092 | 10 1764534 | 10 1451978 | 0 1451977 | 0 1451979 | 0 (7 rows)
References
- PostgreSQL documentation: Per-Backend Statistics Functions