RE: Happy column adding (was RE: [HACKERS] Happy column dropping) - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: Happy column adding (was RE: [HACKERS] Happy column dropping)
Date
Msg-id NDBBIJLOILGIKBGDINDFIEFOCCAA.Inoue@tpf.co.jp
Whole thread Raw
In response to Happy column adding (was RE: [HACKERS] Happy column dropping)  (Peter Eisentraut <e99re41@DoCS.UU.SE>)
List pgsql-hackers
> -----Original Message-----
> From: Hiroshi Inoue [mailto:Inoue@tpf.co.jp]
> > But, considering the fact that DEFAULT can be something reaaly 
> > complex, like
> > function that does a lot of things, it may be better to have the 
> > constraints
> > checked at the end of transaction, like
> > 
> > BEGIN;
> > ALTER TABLE T1 ADD COLUMN C1 TEXT NOT NULL;
> 
> Isn't 'iNITIALLY DEFERRED' needed ?
> ALTER TABLE T1 ADD COLUMN C1 TEXT NOT NULL INITIALLY DEFERRED;
> 
> > UPDATE T1 SET C1='MYDEFAULTVALUE';
> > COMMIT;
> >
> 
> It seems more reasonable than standard.
> But is it worth breaking SQL standard ?
>

Seems I was wrong. It's not so good.
Current spec to reject NOT NULL/DEFAULT for new column
isn't so bad and ADD CONSTRAINT feature is much more
important. How about the following ?

BEGIN;
ALTER TABLE T1 ADD COLUMN C1 TEXT;
UPDATE T1 SET C1='MYDEFAULTVALUE';
ALTER TABLE T1 ADD CONSTRAINT CHECK C1 NOT NULL;
COMMIT;

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp



pgsql-hackers by date:

Previous
From: Zeugswetter Andreas SB
Date:
Subject: AW: AW: AW: [HACKERS] Some notes on optimizer cost estimates
Next
From: Jose Soares
Date:
Subject: Re: Happy column adding (was RE: [HACKERS] Happy column dropping)