Re: Mutable CHECK constraints?

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Mutable CHECK constraints?
Date: 2023-01-24 23:24:00
Message-ID: f4495237cb3e6bf79aeef43bcf8d371394d2d201.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2023-01-24 at 01:38 -0500, Tom Lane wrote:
> Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> > We throw an error if the expression in a CREATE INDEX statement is not IMMUTABLE.
> > But while the documentation notes that expressions in CHECK constraints are not
> > to be immutable, we don't enforce that.  Why don't we call something like
> > CheckMutability inside cookConstraint?  Sure, that wouldn't catch all abuse,
> > but it would be better than nothing.
>
> > There is of course the worry of breaking upgrade for unsafe constraints, but is
> > there any other reason not to enforce immutability?
>
> Yeah, that's exactly it, it's a historical exemption for compatibility
> reasons.  There are discussions about this in the archives, if memory
> serves ... but I'm too tired to go digging.

Thanks for the answer. A search turned up
https://postgr.es/m/AANLkTikwFfvavEX9nDwcRD4_xJb_VAitMeP1IH4wpGIt%40mail.gmail.com

Yours,
Laurenz Albe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-01-24 23:30:19 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Peter Geoghegan 2023-01-24 23:18:10 Re: Update comments in multixact.c