pg_drop_replication_slot()

A function for removing a replication slot

pg_drop_replication_slot() is a system function for removing a physical or logical replication slot.

pg_drop_replication_slot() was added in PostgreSQL 9.4.

Usage

pg_drop_replication_slot ( slot_name name ) → void

The slot to be dropped must be inactive before it can be removed. It is not possible to forcibly drop an active replication slot.

Change history

Examples

Dropping a replication slot using pg_drop_replication_slot():

postgres=# SELECT pg_drop_replication_slot('node2');
 pg_drop_replication_slot 
--------------------------
 
(1 row)

It is not possible to drop an active replication slot:

postgres=# SELECT slot_name, slot_type, active FROM pg_replication_slots;
 slot_name | slot_type | active 
-----------+-----------+--------
 node2     | physical  | t
(1 row)

postgres=# SELECT pg_drop_replication_slot('node2');
ERROR:  replication slot "node2" is active for PID 17675

Attempting to drop a non-existent replication slot:

postgres=# SELECT pg_drop_replication_slot('foo');
ERROR:  replication slot "foo" does not exist

Categories

Replication, System function, WAL

See also

pg_create_physical_replication_slot(), pg_create_logical_replication_slot()