Re: Modifying NOT NULL Constraint - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: Modifying NOT NULL Constraint
Date
Msg-id 00e101bfd636$53dfb0d0$0c64010a@kick.com
Whole thread Raw
In response to Modifying NOT NULL Constraint  ("Dan Wilson" <phpPgAdmin@acucore.com>)
Responses Re: Modifying NOT NULL Constraint  (JanWieck@t-online.de (Jan Wieck))
List pgsql-hackers
> 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).

> You can implement any of these behaviors for yourself with a couple of
> SQL commands inside a transaction, so I'm not sure that I see the need
> to have a neatly-wrapped-up ALTER TABLE command that will only do one
> of the things you might want it to do.
True, but it would be nice to be able to add a check constraint later, and
as
long as you're doing it, it seems silly to ignore NOT NULL.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.0.2 cuts off attribute name
Next
From: Murad Nayal
Date:
Subject: info on unixODBC/Postgres driver port to IRIX 6.5.7 64bit