Contents
pg_terminate_backend()
A function which instructs a backend to terminate
pg_terminate_backend()
is a system function which instructs a backend to terminate.
pg_terminate_backend()
was added in PostgreSQL 8.0.
Usage
PostgreSQL 14 and later:
pg_terminate_backend ( pid INTEGER, timeout BIGINT DEFAULT 0 ) → BOOLEAN
PostgreSQL 13 and earlier:
pg_terminate_backend ( pid INTEGER ) → BOOLEAN
Change history
- PostgreSQL 14
timeout
parameter added (commit aaf04325)
- PostgreSQL 9.2
- non-superusers can terminate their own sessions in other backends (commit c60ca19d)
- PostgreSQL 8.0
- added (commit e8d9d68c)
Examples
Termination of a PostgreSQL backend:
postgres=# SELECT pg_terminate_backend(1306214); pg_terminate_backend ---------------------- t (1 row)
Attempting to terminate a PID which does not belong to the running PostgreSQL instance or does not exist:
postgres=# SELECT pg_terminate_backend(123456); WARNING: PID 123456 is not a PostgreSQL server process pg_terminate_backend ---------------------- f (1 row)
References
- PostgreSQL documentation: Server Signaling Functions