Check constraints on non-immutable keys

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

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?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2010-06-30 14:24:30 Additional startup logging
Previous Message Robert Haas 2010-06-30 11:37:03 Re: Proposal for 9.1: WAL streaming from WAL buffers