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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: dwwoelfel(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19380: Transition table in AFTER INSERT trigger misses rows from MERGE when used with INSERT in a CTE
Date: 2026-01-20 18:00:56
Message-ID: 1698130.1768932056@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)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

Attachment Content-Type Size
fix-transition-table-capture-2.patch text/x-diff 12.8 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-01-20 23:05:41 Re: Revoke Connect Privilege from Database not working
Previous Message Tom Lane 2026-01-20 17:21:20 Re: BUG #19380: Transition table in AFTER INSERT trigger misses rows from MERGE when used with INSERT in a CTE