Re: Happy column adding (was RE: [HACKERS] Happy column dropping)

From: Don Baccus <dhogaza(at)pacifier(dot)com>
To: Hannu Krosing <hannu(at)tm(dot)ee>, Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
Cc: PostgreSQL Development <pgsql-hackers(at)postgreSQL(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Happy column adding (was RE: [HACKERS] Happy column dropping)
Date: 2000-01-26 18:07:50
Message-ID: 3.0.1.32.20000126100750.00fa6340@mail.pacifier.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 10:45 AM 1/26/00 +0200, Hannu Krosing wrote:

>> Do we have to refer default value for already inserted rows ?
>> Doesn't 'default' have its meaning only when rows are about to be
>> inserted ?
>
>I think the case was about adding a NOT NULL column and setting current NULL
>columns to DEFAULT seemed like a natural thing to do.

etc...

It depends on whether we want to be SQL92 compliant. The SQL92 standard
seems to make it clear that "add column ... default" is supposed to
set the column in ALL the rows in the table to that value.

I think it's actually much more useful this way. If you set a default
value, it is normal to write application code that depends on its
existence. If you're going to write your application to work with
the column set to NULL, then you probably don't need the default
anyway.

And...if you don't want to pay the penalty of having to set default
values for all the rows when you add a column with a default value,
you can always add the column without the default value and use a
trigger to set new rows to a default value. This would give the
functionality you want, no?

- Don Baccus, Portland OR <dhogaza(at)pacifier(dot)com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Don Baccus 2000-01-26 18:13:31 RE: [HACKERS] --enable-debug
Previous Message Tom Lane 2000-01-26 17:06:15 Re: AW: AW: [HACKERS] Some notes on optimizer cost estimates