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

From Peter Eisentraut
Subject Re: SET NULL / SET NOT NULL
Date
Msg-id Pine.LNX.4.30.0202212012540.683-100000@peter.localdomain
Whole thread Raw
In response to Re: SET NULL / SET NOT NULL  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Responses Re: SET NULL / SET NOT NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: SET NULL / SET NOT NULL  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
Christopher Kings-Lynne writes:

> 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';

This is standard.

> ALTER TABLE blah ALTER COLUMN col NULL;
> ALTER TABLE blah ALTER COLUMN col NOT NULL;

This is missing a verb.  It can be read as "alter table blah, in
particular, alter column col, (and do what with?) NULL".  Is the NULL part
of the identity of the column?

Using the standard precedent above, how about

ALTER TABLE blah ALTER COLUMN col SET NOT NULL;
ALTER TABLE blah ALTER COLUMN col DROP NOT NULL;

This also avoids the confusing "NULL constraint", which does not say that
the column has to be NULL.

> ALTER TABLE blah ALTER COLUMN col varchar(50);

Here again, there should probably be at least one more word inserted, like
TYPE.

> 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';

Maybe ... ALTER COLUMN col TO text ...

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

A shift/reduce conflict has never stopped us. ;-)

-- 
Peter Eisentraut   peter_e@gmx.net



pgsql-hackers by date:

Previous
From: Jean-Michel POURE
Date:
Subject: Re: fmgr_info: function 20071: cache lookup failed
Next
From: Peter Eisentraut
Date:
Subject: Re: \connect case-folding change maybe not such a good idea