Restrictions of channel arg of pg_notofy

From: Axel Rau <Axel(dot)Rau(at)Chaos1(dot)DE>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Restrictions of channel arg of pg_notofy
Date: 2019-04-27 17:51:46
Message-ID: 023C223F-4FC9-4E9E-A8C6-17F491358FA7@Chaos1.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi everyone!

Can the channel argument derived from the NEW pseudo arg of an INSERT TRIGGER?
In the following trigger function, the
PERFORM pg_notify(fac);
does not work (LISTEN in psql shows no notification).

Any help welcome.
Thanks, Axel

CREATE TRIGGER new_event_trigger AFTER INSERT OR UPDATE ON syslog.event
FOR EACH ROW EXECUTE PROCEDURE syslog.new_event_action();

CREATE OR REPLACE FUNCTION syslog.new_event_action() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
fac TEXT := format('f0%s', NEW.facility);
BEGIN
IF NEW.facility > 9 THEN
fac := format('f%s', NEW.facility);
END IF;
IF NEW.facility = 8 THEN
INSERT INTO pf_event (id) VALUES (NEW.id);
END IF;
PERFORM pg_notify(fac);
RETURN NEW;
END;
$$;

---
PGP-Key:29E99DD6 ☀ computing @ chaos claudius

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2019-04-27 18:51:57 Re: Restrictions of channel arg of pg_notofy
Previous Message Max Lipsky 2019-04-27 07:32:37 Re: Problem in