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.

The following related functions are also available:

Change history

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)

Categories

System function

See also

pg_stat_activity