Re: Using SUBSELECT in CHECK expressions

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Using SUBSELECT in CHECK expressions
Date: 2003-11-05 17:49:06
Message-ID: 59E8621A-0FB8-11D8-B410-0005029FC1A7@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thursday, November 6, 2003, at 02:38 AM, Tom Lane wrote:

> Michael Glaesemann <grzm(at)myrealbox(dot)com> writes:
>> On Wednesday, November 5, 2003, at 06:26 AM, Tom Lane wrote:
>>> Just put the SELECT into a function that's called by the CHECK
>>> expression.
>
>> Tom, you've just provided the solution to something I've been thinking
>> about a lot. I really have to start thinking in terms of functions.
>> Are
>> there any restrictions on the function used in the CHECK, i.e., it
>> must
>> be STRICT or IMMUTABLE?
>
> IIRC we check that it is labeled IMMUTABLE. Whether it really is or
> not, we cannot check (and if it uses a SELECT on tables that could
> change, then of course it isn't; so you are going to need to tell a
> little white lie here).
>
> Because of that, you need to be careful that you pass at least one
> nonconstant argument to the function within the CHECK expression, else
> you risk having the call constant-folded too early. Normally you'd
> probably pass values from the checked row into the function, so this
> doesn't seem like it should be a problem, but I could see someone
> getting bit by it someday ...

Thanks for the clarification. Is this in the documentation somewhere?
I'm not quite used to the new documentation ordering yet.

Michael
grzm myrealbox com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Siegmar 2003-11-05 18:08:02 7.4 is great!
Previous Message Jan Poslusny 2003-11-05 17:42:50 invalid command \