Re: Check constraints on non-immutable keys

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Check constraints on non-immutable keys
Date: 2010-06-30 17:44:41
Message-ID: AANLkTimjcTlahvW08UuxdnZV9SaUZm1TwdjVdQl1IyCd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 30, 2010 at 9:47 AM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> We currently allow this:
>
> postgres=# create table t(a timestamptz not null primary key, check(a > now()));
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
> "t_pkey" for table "t"
> CREATE TABLE
>
>
> Which seems very wrong. For one thing, a dump of this database can not
> be restored if now() has advanced enough into the future (which it
> will eventually). It also makes impossible to do things like SET a=a
> on the table.
>
> Yes, this is clearly a stupidly defined constraint, but why do we allow it?
>
> Shouldn't we disallow anything that's not IMMUTABLE in a check constraint?

suppose you did do this: shouldn't you then also recheck the
constraint if the function is create/replaced?

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gibheer 2010-06-30 18:10:56 Re: LLVM / clang
Previous Message Magnus Hagander 2010-06-30 17:37:37 Re: Check constraints on non-immutable keys