Re: DEFERRABLE NOT NULL constraint

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Gavan Schneider *EXTERN*" <pg-gts(at)snkmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: DEFERRABLE NOT NULL constraint
Date: 2013-02-07 07:45:58
Message-ID: A737B7A37273E048B164557ADEF4A58B057B06E3@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gavan Schneider wrote:
> Taking a different tangent ...

Good idea.

> Is there anything in the SQL standards about NOT NULL
> constraints being deferrable?
>
> To my mind we should not consider implementing non-standard
> behaviour, but if something is in the standard I can't see why
> it shouldn't be implemented, esp. when there is no compulsion
> for it to be used.

ISO/IEC 9075-2:2003 says:

Chapter 11.4 (<column definition>):

<column constraint definition> ::=
[ <constraint name definition> ] <column constraint> [ <constraint characteristics> ]

<column constraint> ::=
NOT NULL
| <unique specification>
| <references specification>
| <check constraint definition>

Chapter 10.8 (<constraint name definition> and <constraint characteristics>):

<constraint characteristics> ::=
<constraint check time> [ [ NOT ] DEFERRABLE ]
| [ NOT ] DEFERRABLE [ <constraint check time> ]

<constraint check time> ::=
INITIALLY DEFERRED
| INITIALLY IMMEDIATE

So yes, the standard caters for deferrable NOT NULL constraints.

Moreover:

Chapter 10.8, General Rules
1) A <constraint name> identifies a constraint. Let the identified constraint be C.
2) If NOT DEFERRABLE is specified, then C is not deferrable; otherwise it is deferrable.

So deferrable should be the default.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben Madin 2013-02-07 07:50:51 Re: ERROR: invalid input syntax for integer: ""
Previous Message Miroslav Šimulčík 2013-02-07 07:29:35 Re: [HACKERS] function for setting/getting same timestamp during whole transaction