Help with ADD COLUMN - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Help with ADD COLUMN
Date
Msg-id 01ac01c2934a$d14c59a0$6500a8c0@internal
Whole thread Raw
Responses Re: Help with ADD COLUMN
Re: Help with ADD COLUMN
List pgsql-hackers
Hi Guys,

I'm starting work on ADD COLUMN.  I'm going to allow:

* SERIAL, SERIAL8
* DEFAULT
* NOT NULL

etc...

The one big programming difficulty I see is the process of running through
all the existing tuples in the relation the column was added to and
evaluating the default for each row.

I assume that's the correct behaviour?  If they specify a default, the
column should be auto-filled with that default, right?

If someone could give me a really quick example look on how to do this, it'd
be really appreciated and would save me heaps of time...

The trick is that the default clause needs to be actually evaluated, not
just set - eg. nextval('"my_seq"') sort of thing.

I guess the other tricky bit is checking that the default value satisfies
the check constraint...?

Chris



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: regression failures
Next
From: Daniele Orlandi
Date:
Subject: Re: Optimizer & boolean syntax