Re: abnormal behaviour of a CHECK CONSTRAINT with a regular - Mailing list pgsql-bugs

From Stephan Szabo
Subject Re: abnormal behaviour of a CHECK CONSTRAINT with a regular
Date
Msg-id 20040210080705.W20734@megazone.bigpanda.com
Whole thread Raw
In response to abnormal behaviour of a CHECK CONSTRAINT with a regular expression when a trigger is added  (Daniel Struck <struck.d@retrovirology.lu>)
List pgsql-bugs
On Tue, 10 Feb 2004, Daniel Struck wrote:

> retrovirology=# INSERT INTO test_reg1 (date_user) VALUES ('111.1999');
> ERROR:  invalid input syntax for type date: "111.1999"
> CONTEXT:  PL/pgSQL function "function_test_reg1" line 8 at assignment
> retrovirology=# INSERT INTO test_reg1 (date_user) VALUES ('11:1999');
> ERROR:  invalid input syntax for type date: "15.11:1999"
> CONTEXT:  PL/pgSQL function "function_test_reg1" line 12 at assignment
> retrovirology=#
>
> This values do pass NOW the CHECK CONSTRAINT ???? and are injected in
> the trigger function. Normally the trigger shouldn't m have an influence
> an the CHECK CONSTRAINT.

Wrong order.  Before triggers happen before the table check constraint is
checked (since the triggers can change the data). IIRC, you can currently
have a constraint that is checked before that currently by making the
column type be a domain that has the constraint since the value gets
coerced to the column type (and checked) when making the row value for the
trigger.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular expression when a trigger is added
Next
From: Daniel Struck
Date:
Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular