UNLISTEN

A utility command to stop listening for a notification

UNLISTEN is a utility command for removing a particular or all registrations for event notifications.

UNLISTEN was added in PostgreSQL 6.4.

Usage

If the client has previously executed LISTEN channel during the session, UNLISTEN will cause it to stop listening for notifications on that channel. Alternatively, UNLISTEN * will cause it to stop listening on all channels.

Change history

Examples

Usage example for UNLISTEN:

postgres=# LISTEN somechannel;
LISTEN

postgres=# LISTEN otherchannel;
LISTEN

postgres=# LISTEN foo;
LISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
 somechannel
 otherchannel
 foo
(3 rows)

postgres=# UNLISTEN foo;
UNLISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
 somechannel
 otherchannel
(2 rows)

postgres=# UNLISTEN *;
UNLISTEN

postgres=# SELECT * FROM pg_listening_channels();
 pg_listening_channels 
-----------------------
(0 rows)

Categories

Asynchronous notifications, Utility command

See also

LISTEN, NOTIFY, pg_listening_channels()