Help with ADD COLUMN

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Help with ADD COLUMN
Date: 2002-11-23 23:48:25
Message-ID: 01ac01c2934a$d14c59a0$6500a8c0@internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniele Orlandi 2002-11-24 03:27:14 Re: Optimizer & boolean syntax
Previous Message Arcadius A. 2002-11-23 22:09:37 SQL query help!