Re: [HACKERS] CHECK constraints inconsistencies

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Glaesemann <grzm(at)myrealbox(dot)com>, pgsql-bugs(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] CHECK constraints inconsistencies
Date: 2004-03-02 01:43:59
Message-ID: 20040302014359.GA24170@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Mar 01, 2004 at 20:28:02 -0500,
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Michael Glaesemann <grzm(at)myrealbox(dot)com> writes:
> > In both cases, the CHECK constraint uses a function that is stable or
> > volatile. It was suggested that functions used in CHECK constraints be
> > restricted to immutable,
>
> This seems reasonable to me. I'm a bit surprised we do not have such a
> check already.

There may be times you want to do this. For example you may want a timestamp
to be in the past. In this case as long as it was in the past when the
data was entered it will continue to be in the past (barring someone
resetting the system time). This is something someone might actually
check unlike comparing to random numbers.

I think just noting that check constraints are only checked on inserts
and updates and that this means that check constraints using volatile
or stable functions need to be well thought out.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Rod Taylor 2004-03-02 02:25:01 Re: CHECK constraints inconsistencies
Previous Message Tom Lane 2004-03-02 01:28:02 Re: [HACKERS] CHECK constraints inconsistencies

Browse pgsql-hackers by date

  From Date Subject
Next Message Curt Sampson 2004-03-02 01:52:52 Re: Check Constraints and pg_dump
Previous Message Andrew Dunstan 2004-03-02 01:32:43 Re: log_line_info