Re: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dave(dot)bath(at)unix(dot)net
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum
Date: 2005-10-27 00:55:31
Message-ID: 13074.1130374531@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Bath, David" <dave(dot)bath(at)unix(dot)net> writes:
> you wrote (2005-10-26 17:00)
>>> Sybase/MS-SQL's check constraint model asserts the constraint
>>> BEFORE the trigger, which discourages you from attempting to>
>>> check and handle meaning of data!

>> Er, doesn't PG do it that way too?

> Well, it works for me!

You're right of course. I was confusing this with a related problem
that people occasionally complain about, which is that datatype-related
errors are thrown before the trigger can do anything about them. For
instance, you can't stuff "abc" into a int4 field and hope that the
trigger will have a chance to replace it with something valid. (Yes,
people have asked for that :-() A less silly example is that domain
constraints on a field of a domain type get checked before the trigger
can run.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Igor Shevchenko 2005-10-27 01:34:58 Re: why vacuum
Previous Message Bath, David 2005-10-27 00:42:10 Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum