public inbox for [email protected]  
help / color / mirror / Atom feed
From: Bharath Rupireddy <[email protected]>
To: Dean Rasheed <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: BUG #19536: UPDATE RETURNING OLD value is stale after concurrent update when table has a BEFORE UPDATE trigger
Date: Tue, 7 Jul 2026 00:38:02 -0700
Message-ID: <CALj2ACXnez0hS_tMhviJRajUxZxbToqay4JJLp8QGSy_kPY9-w@mail.gmail.com> (raw)
In-Reply-To: <CAEZATCWXA4fkO84u+i7KNS3PzC6ak4atnDAABHdax-H-jukU3w@mail.gmail.com>
References: <[email protected]>
	<CALj2ACVThKXik0+X12yEz=78uzUzLZABLj0WKOgH+q-kyvdDcg@mail.gmail.com>
	<CAEZATCW8q47GDba1o+Ji9JUhCHFFbB35D9qMSbBhboCx0GXkQQ@mail.gmail.com>
	<CALj2ACXYQrazMMXe_2bjfFx3DLOb0BDJ4hbx+1eprasX3x_+0A@mail.gmail.com>
	<CAEZATCWXA4fkO84u+i7KNS3PzC6ak4atnDAABHdax-H-jukU3w@mail.gmail.com>

Hi,

On Tue, Jun 30, 2026 at 1:35 AM Dean Rasheed <[email protected]> wrote:
>
> I did think of that, but I was uneasy about copying the trigger's old
> tuple after trigger invocation, in case the trigger scribbled on it
> somehow.

Fair argument. I'm convinced.

> Actually, I think a neater long-term solution would be to move all the
> EPQ rechecking and re-computing of the new tuple out of trigger.c, and
> let the caller deal with it, as we do for the MERGE code

Agreed.

> Yes, that's right. The caller does not initialise context->tmfd at
> all, and ExecUpdatePrologue() doesn't touch it if there are no
> triggers.

That works for me.

> OK, I've added a bunch of tests for those cases. As expected, they
> pass even without the code changes, but it's good to confirm that.

Nice, thank you for adding those.

> > Could we add some context to the error message, e.g., mentioning that
> > this happens after processing the BEFORE UPDATE row triggers? That
> > would make it easier to distinguish from the other similar ones.
>
> I'm pretty sure this is a can't-happen error condition, but OK.

Thanks.

Sorry for the late response. I took a look at the v2 patch, tested it
locally, and it looks good to me. I think we should backpatch this fix
down to PG18 (commit 80feb727c86).

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com






view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: BUG #19536: UPDATE RETURNING OLD value is stale after concurrent update when table has a BEFORE UPDATE trigger
  In-Reply-To: <CALj2ACXnez0hS_tMhviJRajUxZxbToqay4JJLp8QGSy_kPY9-w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox