Re: Expression indexes and dependecies - Mailing list pgsql-hackers

From Pavan Deolasee
Subject Re: Expression indexes and dependecies
Date
Msg-id CABOikdOkRUir+1=62Uhd9i9oS9S5Ju+tPg4cJOk32PrVkZ8cvw@mail.gmail.com
Whole thread Raw
In response to Re: Expression indexes and dependecies  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Expression indexes and dependecies
List pgsql-hackers
On Thu, Jul 25, 2013 at 6:43 PM, Tom Lane <tgl@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,

pgsql-hackers by date:

Previous
From: Tomonari Katsumata
Date:
Subject: Re: comment for "fast promote"
Next
From: Tom Lane
Date:
Subject: Re: Expression indexes and dependecies