On Thu, Jul 25, 2013 at 6:43 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:

>
>
> Well, it's probably somewhat historical, but I doubt we'd want to
> tighten it up now.  Here's an example of a sensible CHECK that's
> only stable:
>
>         create ... last_update timestamptz check (last_update <= now()) ...
>

Agree. That looks like a very sensible use case and something not possible
without support for mutable functions.


>
> More generally, I think the argument was that the behavior of a
> non-immutable CHECK would at least be easy to understand, assuming you
> know that the check will only be applied at row insertion or update.
>

But they are also prone to unexpected behaviour, no ? For example, a slight
variation of the above example is:

    create ... last_update timestamptz check (last_update <= now() and
last_update >= now() - '1 week'::interval) ...

This constraint would most likely fail if someone was to restore the table
from a dump.

Given that we haven't seen any complaints may mean I am imagining a problem
that does not exist in practice, though I thought the example looks quite
sensible too.

Thanks,
Pavan

-- 
Pavan Deolasee
http://www.linkedin.com/in/pavandeolasee

Reply via email to