Thread: LISTEN/NOTIFY Test

LISTEN/NOTIFY Test

From
Josh Berkus
Date:
[TEST REPORT]

[Release]: 9.0 Alpha 4

[Test Type]: Feature Test

[Test]: LISTEN/NOTIFY

[Platform]: OSX 10.5 Intel 32-bit compile

[Parameters]: --with-perl

[Failure]: No.

[Results]: Was able to LISTEN to notifications sent by trigger.

[Comments]: Created a pgbench database.  Added a NOTIFY trigger to
pgbench_history to send notifications of new rows with a payload of tid.
 Set up local listener which received notifications.

create or replace function notify_new_history ()
returns trigger
language plpgsql
as $f$
BEGIN

PERFORM pg_notify('new_history',NEW.tid::TEXT);

return NEW;
END; $f$;

create trigger new_history AFTER INSERT OR UPDATE ON pgbench_history
for each row execute procedure notify_new_history();