Re: SET NULL / SET NOT NULL

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Doug McNaught" <doug(at)wireboard(dot)com>, "Philip Warner" <pjw(at)rhyme(dot)com(dot)au>
Cc: "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SET NULL / SET NOT NULL
Date: 2002-02-21 02:28:51
Message-ID: GNELIHDDFBOCMGBFGEFOGEHPCBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Lockhart 2002-02-21 02:34:06 Re: SET NULL / SET NOT NULL
Previous Message Thomas Lockhart 2002-02-21 02:23:53 Re: date/time compatible problems in 7.2