Re: Expression indexes and dependecies

From: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Expression indexes and dependecies
Date: 2013-07-26 02:55:55
Message-ID: CABOikdOkRUir+1=62Uhd9i9oS9S5Ju+tPg4cJOk32PrVkZ8cvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 25, 2013 at 6:43 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-07-26 03:12:45 Re: Expression indexes and dependecies
Previous Message amutu 2013-07-26 02:23:10 BUG #8335: trim() un-document behaviour