DEFERRABLE NOT NULL constraint - Mailing list pgsql-general

From Andreas Joseph Krogh
Subject DEFERRABLE NOT NULL constraint
Date
Msg-id OrigoEmail.113.e0795ae98d01d64a.13ca67ff059@prod2.officenet.no
Whole thread Raw
Responses Re: DEFERRABLE NOT NULL constraint  (Albe Laurenz <laurenz.albe@wien.gv.at>)
List pgsql-general
It's currently (9.2) not possible to define DEFERRABLE NOT NULL constr=
aints. Meaning the following is not valid:

=C2=A0

CREATE TABLE my_table(

id varchar PRIMARY KEY,

stuff_id BIGINT NOT NULL DEFERRABLE INITIALLY DEFERRED

);

=C2=A0

While it's possible to define a trigger to enforce this, like this:</d=
iv>

=C2=A0


CREATE CONSTRAINT TRIGGER my_table_t AFTER INSERT OR UPDATE ON onp_crm=
_relation DEFERRABLE INITIALLY DEFERRED

FOR EACH ROW EXECUTE PROCEDURE my_table_check_stuff_id_nn_tf();

=C2=A0


And have the my_table_check_stuff_id_nn_tf() raise an exception=
 if "stuff_id" is null.

=C2=A0

Having deferrable constraints on FKs and UKs is really nice and when w=
orking with ORMs it's almost impossible to not use this feature.

=C2=A0

Are there any plans to make NOT NULL constraints deferrable so one can=
 avoid the trigger "boilerplate"?

=C2=A0

--
Andreas Joseph Krogh <andreak@officenet.no>=C2=A0 =C2=A0 =C2=A0 mob: =
+47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc=

pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: Re: Adding PRIMARY KEY: Table contains duplicated values
Next
From:
Date:
Subject: Options for passing values to triggers?