Обсуждение: Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side

Поиск
Список
Период
Сортировка

Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side

От
Avi Weinberg
Дата:

Hi Hackers,

 

There is no error or warning when creating FOR EACH STATEMENT trigger on  Logical Replication subscriber side, but it is not 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();

 

Thanks

 

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

Re: Warning When Creating FOR EACH STATEMENT Trigger On Logical Replication Subscriber Side

От
Amit Kapila
Дата:
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.