Add comments about fire_triggers argument in ri_triggers.c

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Add comments about fire_triggers argument in ri_triggers.c
Date: 2025-03-31 12:26:48
Message-ID: 20250331212648.ad4ab804559001d7f0788741@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

SPI_execute_snapshot() has a argument called "fire_triggers". If this is false,
AFTER triggers are postponed to end of the query. This is true in normal case,
but set to false in RI triggers.

This is introduced by 9cb84097623e in 2007. It is aimed to fire check triggers
after all RI updates on the same row are complete.

However, I cannot find explanation of"why this is required" in the codebase.
Therefore, I've attached a patch add comments in ri_trigger.c for explaining why
fire_triggers is specified to false.

SPI_execute_snapshot() are used in a few places in ri_trigger.c, but I added
the comments only in ri_PerformCheck() because SPI_execute_snapshot() are used
only for SELECT quereis in other places. Therefore, I wonder fire_triggers is
not needed to be false in these places, but I left them as is.

Regards,
Yugo Nagata

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

Attachment Content-Type Size
add_comments_fire_triggers_in_ri_triggers.patch text/x-diff 759 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-03-31 13:05:24 Re: Fwd: [BUG]: the walsender does not update its IO statistics until it exits
Previous Message jian he 2025-03-31 12:25:35 Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints