Re: BUG #16158: Check constraints using SQL functions work incorrectly - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16158: Check constraints using SQL functions work incorrectly
Date
Msg-id 5139.1575990871@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16158: Check constraints using SQL functions work incorrectly  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.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



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #16158: Check constraints using SQL functions work incorrectly
Next
From: Tom Lane
Date:
Subject: Re: BUG #16158: Check constraints using SQL functions work incorrectly