Re: abnormal behaviour of a CHECK CONSTRAINT with a regular

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Daniel Struck <struck(dot)d(at)retrovirology(dot)lu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular
Date: 2004-02-10 16:10:13
Message-ID: 20040210080705.W20734@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-02-10 16:12:39 Re: [BUGS] Probably a security bug in PostgreSQL rule system
Previous Message Daniel Struck 2004-02-10 16:08:58 Re: abnormal behaviour of a CHECK CONSTRAINT with a regular