agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: itdev@itdevel.internal.net, pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: functions allowed in CHECK constraints
Date: Fri, 09 Feb 2018 09:32:16 -0500
Message-ID: <1002.1518186736@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwY6=rJ0J+b9b4VQ=JkJUTdv95N9bmUE9MZojzdetJM3Ow@mail.gmail.com>
References: <8d319874-ea46-d44f-29df-b6ecde7ce9c4@itdevel.internal.net>
<CAKFQuwY6=rJ0J+b9b4VQ=JkJUTdv95N9bmUE9MZojzdetJM3Ow@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Feb 9, 2018 at 1:37 AM, Achilleas Mantzios <
> itdev@itdevel.internal.net> wrote:
>> So, what's the point in forbidding the use of subselects if one can use
>> functions? And OTOH if effectively doing so is bad for some reason, why let
>> it happen with a function?
> Short answer, the system treats the function as a black-box and doesn't
> know that you've used it to circumvent its prohibition on subselects. The
> prohibition still is in place though. If you use a function you are
> expected to ensure you do not violate any of the restrictions yourself.
Actually, I'd say that the possibility to use a function is a workaround
for the fact that you can't write a sub-select directly ;-). The latter
is more of an implementation restriction than anything else, stemming
from the fact that we don't run CHECK expressions through the planner.
Now, it's certainly true that you can use a sub-select to write a
non-immutable CHECK expression and thereby shoot yourself in the foot.
But you can shoot yourself in the foot that way without sub-selects,
too. We do not try to enforce that CHECK expressions are immutable.
regards, tom lane
view thread (6+ messages)
Message-ID: <1002.1518186736@sss.pgh.pa.us>
Permalink: ../1002.1518186736@sss.pgh.pa.us/
Also on: postgresql.org/message-id/1002.1518186736@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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: functions allowed in CHECK constraints
In-Reply-To: <1002.1518186736@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox