> I don't see any bug here; it's just that CHECK constraints are applied
> after any BEFORE triggers are run. Since the triggers could change the
> data to be inserted, the reverse order would be insecure.
Ups, it did make some false assumptions.
Thank you for the clarification.
If I understood now correctly, first the type, then the trigger and last the check constraint is checked.
This makes it also impossible to change the type of a value by a trigger?
Say I would want to change the input of a user to a date, this wouldn't be possible, because in first instance the type is not a date.
Here is an example I tried out:
CREATE TABLE test(datum DATE);
CREATE OR REPLACE FUNCTION function_test()
new.datum := (''15.06.'' || new.datum)::date;
CREATE TRIGGER trigger_test
BEFORE INSERT OR UPDATE
ON test FOR EACH ROW
EXECUTE PROCEDURE function_test();
INSERT INTO test VALUES('2003');
Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barblé
In response to
pgsql-bugs by date
|Next:||From: Stephan Szabo||Date: 2004-02-10 16:10:13|
|Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular|
|Previous:||From: Tom Lane||Date: 2004-02-10 15:38:40|
|Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular expression when a trigger is added |