Re: When UPDATE a row in a table with BEFORE ROW UPDATE trigger, the XMAX of new tuple is set to current XID

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Charles Qi <qyqgpower(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
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: 2025-08-06 18:22:28
Message-ID: 1f99e5c1-a203-4441-aa5c-33a3baaf852c@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message suporte02@unitsistemas.com.br 2025-08-06 18:24:06 Re: Libpq.dll
Previous Message Nathan Bossart 2025-08-06 18:14:12 Re: analyze-in-stages post upgrade questions