select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SYSTEM ADMINISTRATION FUNCTIONS

pg_cancel_backend

Read PG 18 manual ↗

Cancels the current query of the session whose backend process has the specified process ID.

Signatures & examples

pg_cancel_backend ( pid integer ) → boolean
Cancels the current query of the session whose backend process has the specified process ID. This is also allowed if the calling role is a member of the role whose backend is being canceled or the calling role has privileges of pg_signal_backend, however only superusers can cancel superuser backends. As an exception, roles with privileges of pg_signal_autovacuum_worker are permitted to cancel autovacuum worker processes, which are otherwise considered superuser backends.
Version history 6
  1. PG 17 → 18changed
  2. PG 14 → 15changed
  3. PG 12 → 13changed
  4. PG 9.5 → 9.6changed
  5. PG 9.4 → 9.5changed
  6. PG 9.1 → 9.2changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source