The event mechanism is available across the whole database. This means that it is possible to build clients that get notified about events or push events. In order to demonstrate how this is possible, let's build a client application that will get notified by new musical file events.
We'll start with a Perl example, shown in Listing 9. The program connects to the database and performs the LISTEN command, then does an infinite loop, invoking the special pg_notifies driver function. The pg_notifies function polls for a new event and returns an array reference with the element of the array set to the channel name, PID, and payload respectively. Since the payload is the primary key of the fresh ...