Re: BUG #16158: Check constraints using SQL functions work incorrectly

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pjander2(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16158: Check constraints using SQL functions work incorrectly
Date: 2019-12-10 15:14:31
Message-ID: 5139.1575990871@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> Summary: I defined a check constraint `project_limits` using
> [SQL functions](https://www.postgresql.org/docs/9.1/xfunc-sql.html).

This is not a bug; you've ignored the restriction that check constraints
must be immutable. See the "Notes" at the bottom of this section:

https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-CHECK-CONSTRAINTS

In the particular case at hand, I think the behavior you're complaining
about stems from the fact that the CHECK condition is evaluated before
the actual row insertion has happened.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-12-10 15:39:59 Re: BUG #16158: Check constraints using SQL functions work incorrectly
Previous Message David G. Johnston 2019-12-10 15:00:24 Re: BUG #16158: Check constraints using SQL functions work incorrectly