Re: SET NULL / SET NOT NULL - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: SET NULL / SET NOT NULL
Date
Msg-id GNELIHDDFBOCMGBFGEFOGEHPCBAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: SET NULL / SET NOT NULL  (Doug McNaught <doug@wireboard.com>)
Responses Re: SET NULL / SET NOT NULL  (Philip Warner <pjw@rhyme.com.au>)
Re: SET NULL / SET NOT NULL  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
> > I'm not too fond of 'SET NULL' - the syntax implies the column
> is being set
> > to NULL. But I agree with the rest given we already have ALTER
> > TABLE...ALTER COLUMN, I'd vote for:
> >
> >     ALTER TABLE blah ALTER COLUMN col [ALLOW NULL | NOT NULL]
>
> FWIW, I like this syntax too.

Let's say, theoretically, that in the future we want to allow people to
change the type of their columns, plus allow them to change the nullability.

Should we come up with a syntax for changing nullability that allows for the
future changing of column type?  If so, then a syntaxes like these might be
the way to go:

ALTER TABLE blah ALTER COLUMN col DROP DEFAULT;
ALTER TABLE blah ALTER COLUMN col SET DEFAULT 't';
ALTER TABLE blah ALTER COLUMN col NULL;
ALTER TABLE blah ALTER COLUMN col NOT NULL;
ALTER TABLE blah ALTER COLUMN col varchar(50);
ALTER TABLE blah ALTER COLUMN col int4 NULL;
ALTER TABLE blah ALTER COLUMN col text NOT NULL;

If we just allow the full col spec we could one day support this:

ALTER TABLE blah ALTER COLUMN col text boolean NOT NULL DEFAULT 'f';

Which would change the column to that definition (if coercion is possible)
no matter what current definition is...

Is this the eventual goal?  Will this cause shift/reduce errors? will we
need to put the word 'SET' in after 'col'?

Chris



pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: date/time compatible problems in 7.2
Next
From: Thomas Lockhart
Date:
Subject: Re: SET NULL / SET NOT NULL