pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pjander2@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16158: Check constraints using SQL functions work incorrectly
Date: Tue, 10 Dec 2019 10:14:31 -0500
Message-ID: <5139.1575990871@sss.pgh.pa.us> (raw)
In-Reply-To: <16158-7ccf2f74b3d655db@postgresql.org>
References: <16158-7ccf2f74b3d655db@postgresql.org>

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





view thread (4+ messages)  latest in thread

Message-ID: <5139.1575990871@sss.pgh.pa.us>
Permalink:  ../5139.1575990871@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5139.1575990871@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pjander2@gmail.com
  Subject: Re: BUG #16158: Check constraints using SQL functions work incorrectly
  In-Reply-To: <5139.1575990871@sss.pgh.pa.us>
  References: <16158-7ccf2f74b3d655db@postgresql.org> <5139.1575990871@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox