Re: Mutable CHECK constraints?

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

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-01-24 06:57:56 Re: Generating code for query jumbling through gen_node_support.pl
Previous Message Dilip Kumar 2023-01-24 06:17:13 Re: [PoC] Improve dead tuple storage for lazy vacuum