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

From Laurenz Albe
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
Msg-id 41cc55f13edfc22ab393fa27b54ca6b7fed32ee9.camel@cybertec.at
Whole thread Raw
In response to Re: When UPDATE a row in a table with BEFORE ROW UPDATE trigger, the XMAX of new tuple is set to current XID  (Charles Qi <qyqgpower@gmail.com>)
List pgsql-general
On Mon, 2025-08-11 at 11:34 +0800, Charles Qi wrote:
> The trigger function in example is doing nothing but return new, the
> row is actually locked by the trigger itself (trigger.c >
> ExecBRUpdateTriggers > GetTupleForTrigger)
>
> You mentioned a very important behavior:
> > A multixact is only necessary
> > if a subtransaction needs to take a stronger lock on the row than what
> > was there before.
>
> We are doing two no key updates in example, and should not need a
> stronger lock on the same row.

Still, you could explicitly lock the row in the trigger function with
a high enough lock level to avoid a multixact being created later on.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Justin
Date:
Subject: Re: Questions about the continuity of WAL archiving
Next
From: px shi
Date:
Subject: Re: Questions about the continuity of WAL archiving