Re: subselect in CHECK constraint?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ian Turner <vectro(at)pipeline(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: subselect in CHECK constraint?
Date: 2000-09-04 17:10:11
Message-ID: 14579.968087411@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ian Turner <vectro(at)pipeline(dot)com> writes:
> Uhhh. I get no errors, but it dosen't work, either. Consider:

I didn't say that you would like the semantics ;-).

The check constraint is going to be evaluated *before* the proposed
new tuple is inserted into the table, not after; so doing a select
on the same table won't see the new tuple.

Also, as several other people already pointed out, a constraint
involving a select could be violated in many ways including alteration
or removal of tuples in other tables. We only evaluate check
constraints when we insert/update tuples in the table they are attached
to...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rafa Couto 2000-09-04 17:12:22 RE: Postgres 7.0.2 and ODBC
Previous Message Papp Gyozo 2000-09-04 16:53:47