Re: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum - Mailing list pgsql-sql

From Tom Lane
Subject Re: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum
Date
Msg-id 13074.1130374531@sss.pgh.pa.us
Whole thread Raw
In response to Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum  ("Bath, David" <dave.bath@unix.net>)
List pgsql-sql
"Bath, David" <dave.bath@unix.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


pgsql-sql by date:

Previous
From: "Bath, David"
Date:
Subject: Yes, pg does triggers first before asserting check constraints! Was Re: why vacuum
Next
From: Igor Shevchenko
Date:
Subject: Re: why vacuum