Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Richard Guo <guofenglinux(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger
Date: 2024-01-12 17:28:26
Message-ID: 492826.1705080506@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> 12.01.2024 17:56, Robert Haas wrote:
>> I don't understand why it's ever safe to skip ExecMaterializeSlot
>> here. IIUC, if we have no EPQ slot, newslot is still not materialized
>> and thus dependent on oldslot ... and we're about to
>> ExecFetchSlotHeapTuple on oldslot.

> To my understanding, when we have no epqslot_candidate, it means that
> newslot came from ExecBRUpdateTriggers's callers and it can't be dependent
> on an internal oldslot's buffer.

After sleeping on it, I'm inclined to the opinion that unconditionally
materializing newslot here is a good idea. Given that we're about to
call one or more trigger functions, the incremental cost ought to be
pretty negligible. The reduction in the state space that we have to
reason about seems fairly significant, too. Remember that a trigger
function could do almost anything. So I like this not only for
providing a straightforward fix for the current problem, but as a
guard against unrecognized or future bugs in this area. 75e03eabe
should be sufficient evidence that there's a lot of hazard here
(and I especially like being able to revert that wart).

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-01-12 17:57:55 BUG #18289: postgresql14-devel-14.10-2PGDG.rhel8.x86_64.rpm Contains invalid cLang option in Makefile.global
Previous Message Alexander Lakhin 2024-01-12 17:00:01 Re: BUG #17798: Incorrect memory access occurs when using BEFORE ROW UPDATE trigger