Re: BUG #16158: Check constraints using SQL functions work incorrectly
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pjander2@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2019-12-10T15:14:31Z
Lists: 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
Commits
-
Doc: back-patch documentation about limitations of CHECK constraints.
- af4006f0097a 10.12 landed
- 7ef59c9b1839 9.6.17 landed
- 6bf23e8c6e06 9.5.21 landed
- 49b83f647434 11.7 landed
- 3ddd8ee7167f 9.4.26 landed