Re: Adding a stored generated column without long-lived locks - Mailing list pgsql-hackers

From Laurenz Albe
Subject Re: Adding a stored generated column without long-lived locks
Date
Msg-id 27824d022b9ddf7edcaa11f450a6cb29b4f3fe7a.camel@cybertec.at
Whole thread
In response to Re: Adding a stored generated column without long-lived locks  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
List pgsql-hackers
On Fri, 2026-10-02 at 18:58 +0200, Matthias van de Meent wrote:
> On Fri, 2 Oct 2026 at 09:30, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> >
> > You could simply require the constraint to be
> >
> >   ROW(col)::record *= ROW(expression)::record
> >
> > That would also behave as desired for NULL values.
> >
> > True, it looks hacky, but as you said, it is a constraint created
> > for this special purpose.
>
> I don't think that's a good solution:  Whilst it may work, it also
> adds significant and potentially unnecessary overhead to the execution
> of the CHECK constraint.  The added complexity in the expression
> itself also increases the chance of a user defining the constraint
> incorrectly.

All of that is correct, but the constraint is not permanent, so you don't
have to pay the slight overhead for the more complicated expression
permanently.  If the user defines the constraint wrongly, nothing bad
can happen: ALTER TABLE will complain that there is no appropriate
constraint.  Probably annoying, but no damage done.

Yours,
Laurenz Albe



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: injection_points: canceled or terminated waiters leak their wait slots
Next
From: Manu
Date:
Subject: Re: Fix reindexdb with parallel index-level conrurrent run