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

From Christopher Kings-Lynne
Subject Re: SET NULL / SET NOT NULL
Date
Msg-id GNELIHDDFBOCMGBFGEFOGENJCBAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: SET NULL / SET NOT NULL  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: SET NULL / SET NOT NULL  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
List pgsql-hackers
> OK, how about:
>
>     SET CONSTRAINT NOT NULL
>
> or
>
>     DROP CONSTRAINT NOT NULL
>
> or simply:
>
>     SET/DROP NOT NULL
>
> I think the problem with trying to get it look like CREATE TABLE is that
> the plain NULL parameter to CREATE TABLE is meaningless and probably
> should never be used.  I remember at one point pg_dump output NULL in
> the schema output and it confused many people. NOT NULL is the
> constraint, and I think any solution to remove NOT NULL has to include
> the NOT NULL keyword.  I think this is also why SET NULL looks so bad.
> "CREATE TABLE test (x int NULL)" doesn't look great either.  :-)  What
> is that NULL doing there?

OK, I've decided to go with:

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

and

ALTER TABLE blah ALTER [COLUMN] col DROP NOT NULL;

This is synchronous with the SET/DROP default stuff and is extensible in the
future to fit in with column type changing.

Of course, it can always be changed in the parser without affecting my code.

Chris



pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: Configuring for 64-bit integer date/time storage?
Next
From: Ulrich Neumann
Date:
Subject: Antw: Re: patch for include/utils/datetime.h to target NetWare