Re: Modifying NOT NULL Constraint

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: Stephan Szabo <sszabo(at)kick(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Modifying NOT NULL Constraint
Date: 2000-06-14 20:59:48
Message-ID: 200006142059.WAA07939@hot.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Stephan Szabo wrote:
> > What do you think should happen if there are null values? Refuse the
> > command? Delete the non-compliant rows? Allow the rows to remain
> > even though the column is now nominally NOT NULL?
>
> With ALTER TABLE ADD CONSTRAINT on a non-deferrable NOT
> NULL it should fail. At the end of statement the constraint is not
> satified,
> an exception is raised and the statement is effectively ignored. It's alot
> more complicated for deferrable constraints, and I didn't even actually
> take that into account when I did the foreign key one (because I just
> thought
> of it now).

Forget it!

Doing

BEGIN;
ALTER TABLE tab ADD CONSTRAINT ... INITIALLY DEFERRED;
UPDATE tab SET ... WHERE ... ISNULL;
COMMIT;

is totally pathetic. Do it the other way round and the ALTER
TABLE is happy. As Tom usually says "if it hurts, don't do
it". We have more important problems to spend our time for.

Jan

BTW: Still have your other FK related mail to process. Will do so soon.

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew McMillan 2000-06-14 22:38:22 Re: 7.0.2 cuts off attribute name
Previous Message Jan Wieck 2000-06-14 20:43:39 Re: Big 7.1 open items