Deferred NOT NULL?

Started by Gregory Woodabout 25 years ago3 messagesgeneral
Jump to latest
#1Gregory Wood
gregw@com-stock.com

I'd like to create a new table with a NOT NULL constraint that is deferred
until the transaction commit. Unfortunately with this definition:

CREATE TABLE foo (bar INTEGER NOT NULL INITIALLY DEFERRED);

I get this error:

ERROR: Misplaced INITIALLY DEFERRED clause

Is it possible to do this or do I have to define it as a CHECK constraint
and defer that?

Greg

#2Gregory Wood
gregw@com-stock.com
In reply to: Gregory Wood (#1)
Re: Deferred NOT NULL?

Hmmmm, I just found a clearer grammar description in the docs and it appears
that only REFERENCES constraints are deferrable in PostgreSQL. I suppose
I'll have to handle this via a trigger for now.

The book mentions that SQL92 allows for deferrable NOT NULL constraints. Is
this planned for anytime soon?

Gerg

Show quoted text

I'd like to create a new table with a NOT NULL constraint that is deferred
until the transaction commit. Unfortunately with this definition:

CREATE TABLE foo (bar INTEGER NOT NULL INITIALLY DEFERRED);

I get this error:

ERROR: Misplaced INITIALLY DEFERRED clause

Is it possible to do this or do I have to define it as a CHECK constraint
and defer that?

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gregory Wood (#2)
Re: Re: Deferred NOT NULL?

"Gregory Wood" <gregw@com-stock.com> writes:

Hmmmm, I just found a clearer grammar description in the docs and it appears
that only REFERENCES constraints are deferrable in PostgreSQL. I suppose
I'll have to handle this via a trigger for now.

The book mentions that SQL92 allows for deferrable NOT NULL constraints. Is
this planned for anytime soon?

This is (or should be) on the TODO list, but I don't know of anyone with
near-term plans to fix it. The whole area of constraints could use an
overhaul, see past discussions in pghackers.

regards, tom lane