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

From Christopher Kings-Lynne
Subject Re: SET NULL / SET NOT NULL
Date
Msg-id GNELIHDDFBOCMGBFGEFOKENGCBAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: SET NULL / SET NOT NULL  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: SET NULL / SET NOT NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: SET NULL / SET NOT NULL  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Hi,

I'm halfway thru implementing setting a column's nullness (I've done
changing to null,
but not changing to not null)

Peter E. said:

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

Do we want the above syntax, or this syntax:

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

The former sort of treats it like a contraint, where as the latter treats it
as it is during the CREATE TABLE statement.

Say in the future we want to support changing column type as well.  How
would we work that in?

ALTER TABLE blah ALTER COLUMN col SET int4;  ??????

Then we should allow people to do this:

ALTER TABLE blah ALTER COLUMN col SET int4 NULL DEFAULT '3';

So they can change their entire column in one statement.

So really this implies that ALTER COLUMN/SET NULL is the correct syntax,
rather than ALTER COLUMN/DROP NOT NULL.  In fact, maybe we could support
BOTH syntaxes...

Comments?  Let's sort this out before I submit my patch.

Regards,

Chris



pgsql-hackers by date:

Previous
From: "Nicolas Bazin"
Date:
Subject: Re: Where to get official SQL spec (was Re: Domain Support)
Next
From: Tom Lane
Date:
Subject: Re: SET NULL / SET NOT NULL