Updated on 2025-08-25 GMT+08:00

Session Information Functions

pg_backend_pid()

Description: Process ID of the service process connected to the current session.

Return type: integer.

Example:

1
2
3
4
5
postgres=#SELECT pg_backend_pid();
 pg_backend_pid
-----------------
 140229352617744
(1 row)

pg_conf_load_time()

Description: Configuration load time. pg_conf_load_time returns the timestamp when the server configuration file was last loaded.

Return type: timestamp with time zone.

Example:

1
2
3
4
5
postgres=#SELECT pg_conf_load_time();
      pg_conf_load_time       
------------------------------
 2017-09-01 16:05:23.89868+08
(1 row)

pg_postmaster_start_time()

Description: Server start time. pg_postmaster_start_time returns the timestamp with time zone when the server started.

Return type: timestamp with time zone.

Example:

1
2
3
4
5
postgres=#SELECT pg_postmaster_start_time();
   pg_postmaster_start_time   
------------------------------
 2017-08-30 16:02:54.99854+08
(1 row)

pgxc_version()

Description: pgname version information.

Return type: text.

Example:

1
2
3
4
5
postgres=#SELECT pgxc_version();
                                                pgxc_version                                                 
-------------------------------------------------------------------------------------------------------------
 Postgres-XC 1.1 on x86_64-unknown-linux-gnu, based on PostgreSQL 9.2.4, compiled by g++ (GCC) 5.4.0, 64-bit
(1 row)

session_user

Description: Session username. session_user is typically the initial user who connects to the current database.

Return type: name.

Example:

1
2
3
4
5
postgres=#SELECT session_user;
 session_user
--------------
 DB user NEW
(1 row)

user

Description: Equivalent to current_user.

Return type: name.

Example:

1
2
3
4
5
postgres=#SELECT user;
 current_user
--------------
 DB user NEW
(1 row)

version()

Description: Version information. version returns a string describing the server's version information.

Return type: text.

Example:

1
2
3
4
5
postgres=#SELECT version();
                                                                version                                                                
---------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.2.4 gsql ((GaussDB 8.2.1 build 39137c2d) compiled at 2022-09-23 15:43:11 commit 3629 last mr 5138 release) on x86_64-unknown-linux-gnu, compiled by g++ (GCC) 5.4.0, 64-bit
(1 row)