public inbox for [email protected]  
help / color / mirror / Atom feed
From: Charles Qi <[email protected]>
To: Adrian Klaver <[email protected]>
Cc: [email protected]
Subject: Re: When UPDATE a row in a table with BEFORE ROW UPDATE trigger, the XMAX of new tuple is set to current XID
Date: Fri, 8 Aug 2025 09:20:00 +0800
Message-ID: <CAEawgcLdD3-4Co8mrR7UaXJLGgBwSecUs-1QxyY3VoJzN9bnmg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAEawgcJN2V0MTzZu5gi=csNapnJzogxJJqUFSphu6r=OXjorng@mail.gmail.com>
	<[email protected]>

As I stated before, when the BEFORE ROW UPDATE trigger is absent, even
if we update the same row in multiple subtransactions inside one top
transaction, no multixact will be created.
Check the attached no_multi.sql for example.

Let me clarify the question, when the BEFORE ROW UPDATE trigger is presented
Q. Why do we need to set the XMAX of the new tuple to the current xid?
which risks piling up multixacts quickly in savepoint/exception block
scenarios.


On Thu, Aug 7, 2025 at 2:22 AM Adrian Klaver <[email protected]> wrote:
>
> On 8/6/25 05:37, Charles Qi wrote:
> > And if we do the updates in multiple subtransactions, multixact will be
> > created, which is not created when the BEFORE ROW UPDATE trigger is absent.
> >
> > Is this behavior by design? If so, what is the purpose for the behavior?
>
> I would say this is by design. My reasoning is that the savepoints are
> essentially rollback points and the state of the tuple would need to be
> saved for each potential rollback. Hence a different transaction id for
> each savepoint.
>
> >
> > Tested version:
> > PostgreSQL 14.18 (Ubuntu 14.18-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu,
> > compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
> >
> > The attached file reproduce.sql can be used to reproduce the behavior.
>
>
> --
> Adrian Klaver
> [email protected]


Attachments:

  [application/octet-stream] no_multi.sql (1.6K, 2-no_multi.sql)
  download

view thread (5+ 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]
  Subject: Re: When UPDATE a row in a table with BEFORE ROW UPDATE trigger, the XMAX of new tuple is set to current XID
  In-Reply-To: <CAEawgcLdD3-4Co8mrR7UaXJLGgBwSecUs-1QxyY3VoJzN9bnmg@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