Re: BUG #19380: Transition table in AFTER INSERT trigger misses rows from MERGE when used with INSERT in a CTE

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: dwwoelfel@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2026-01-20T18:00:56Z
Lists: pgsql-bugs

Attachments

I wrote:
> Dean Rasheed <dean.a.rasheed@gmail.com> writes:
>> Attached is a rough patch doing that.

> I haven't read this in detail,

Okay, I've now been through it more carefully, and it looks good
except for these nitpicks (addressed in v2 patch attached):

* I think GetAfterTriggersTableData() ought to have an Assert that
the cmdType used as lookup key is INSERT/UPDATE/DELETE and nothing
else.

* Corrected grammar in comment in MakeTransitionCaptureState.

* Added comment in new switch in AfterTriggerSaveEvent.

One could argue that that new switch should have an explicit
case for TRIGGER_EVENT_TRUNCATE and then the default: should
be elog(ERROR).  That seems excessive to me, given that the
switch earlier in the same function vetted the event value.
But others might see it differently.

			regards, tom lane

Commits

  1. Update .abi-compliance-history for change to TransitionCaptureState.

  2. Fix trigger transition table capture for MERGE in CTE queries.