Re: Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side
Date
Msg-id CAA4eK1+32_hB6O2jz0ww6ympJB5UwofiyWa=Pq3g21RRdCB5WA@mail.gmail.com
Whole thread Raw
In response to Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side  (Avi Weinberg <AviW@gilat.com>)
List pgsql-hackers
On Thu, Dec 1, 2022 at 7:29 PM Avi Weinberg <AviW@gilat.com> wrote:
>
>
> There is no error or warning when creating FOR EACH STATEMENT trigger on  Logical Replication subscriber side, but it
isnot doing anything.  Shouldn't a warning be helpful?
 
>
>
>
> CREATE TRIGGER set_updated_time_trig
>
>    AFTER INSERT OR UPDATE OR DELETE ON test
>
>     FOR EACH STATEMENT EXECUTE FUNCTION set_updated_time();
>

I think we need to consider a few things for this. First, how will we
decide whether a particular node is a subscriber-side? One can create
a subscription after creating the trigger. Also, it won't be
straightforward to know whether the particular table is involved in
the replication. Second, the statement triggers do get fired during
initial sync, see docs [1] (The logical replication apply process
currently only fires row triggers, not statement triggers. The initial
table synchronization, however, is implemented like a COPY command and
thus fires both row and statement triggers for INSERT.). So,
considering these points, I don't know if it is worth showing a
WARNING here.

[1] - https://www.postgresql.org/docs/devel/logical-replication-architecture.html

-- 
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Missing MaterialPath support in reparameterize_path_by_child
Next
From: Andres Freund
Date:
Subject: Re: Failed Assert while pgstat_unlink_relation