Skip to Main Content
Practical PostgreSQL
book

Practical PostgreSQL

by Joshua D. Drake, John C. Worsley
January 2002
Intermediate to advanced content levelIntermediate to advanced
640 pages
16h 39m
English
O'Reilly Media, Inc.
Content preview from Practical PostgreSQL

Listen

Listen for a notification event.

Synopsis

LISTEN name

Parameters

name

The name of the notify condition for which you want the backend to listen.

Results

LISTEN

The message returned when a command is successful, and the backend process is listening for notification.

NOTICE: Async_Listen: We are already listening on name

The notice returned if the backend is already listening for the specified notify condition name.

Description

The NOTIFY and LISTEN commands work together to create a system for PostgreSQL components to communicate between themselves. Use the LISTEN command to start the backend process listening for a notification named name. Notifications are passed by the NOTIFY command, which is usually placed in rules related to changes of various database components; in this way, notifications are sent out to listeners when things are changed.

All running backend processes that are listening for a specific notification are sent that notification when a NOTIFY command is issued for it by any of the processes. When a backend process receives a notification, that notification is sent to the client application (such as psql), which then handles the notification in whatever manner it is written for. For more information about this method of IPC (inter-process communication), see the reference entry titled “NOTIFY.”

You can use any valid string no longer than 31 characters for the name of the notification to listen for (this is also true for the NOTIFY command). To stop a backend process from ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL: Up and Running, 2nd Edition

PostgreSQL: Up and Running, 2nd Edition

Regina O. Obe, Leo S. Hsu
Learning PostgreSQL 11 - Third Edition

Learning PostgreSQL 11 - Third Edition

Christopher Travers, Andrey Volkov
Learn PostgreSQL

Learn PostgreSQL

Luca Ferrari, Enrico Pirozzi
PostgreSQL 13 Cookbook

PostgreSQL 13 Cookbook

Vallarapu Naga Avinash Kumar

Publisher Resources

ISBN: 9781449309770Supplemental ContentErrata Page