Re: [COMMITTERS] pgsql: Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.
Date: 2011-01-26 15:46:57
Message-ID: AANLkTinfF=v7YyoTr4DFoNkk_Ev3AkQcWGLNoEh5f7as@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Wed, Jan 26, 2011 at 10:36 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <rhaas(at)postgresql(dot)org> writes:
>> Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.
>> The previous coding prevented ALTER TABLE .. ADD COLUMN from being used
>> with a non-NULL default in situations where the table's rowtype was being
>> used elsewhere.  But this is a completely arbitrary restriction since
>> you could do the same operation in multiple steps (add the column, add
>> the default, update the table).
>
> This is not an "arbitrary restriction" because according to the SQL
> standard those operations mean different things.  In the first case you
> get a column filled with the default value, in the second case you get a
> column filled with nulls.  And the latter case is the only one that
> works properly with a rowtype.

That's an untenable interpretation. If you set a default on a table
column, it has no effect on the row type.

rhaas=# create table foo (a int default 1);
CREATE TABLE
rhaas=# create table bar (b foo);
CREATE TABLE
rhaas=# insert into bar values (default);
INSERT 0 1
rhaas=# select * from bar;
b
---

(1 row)

I can't see any reason why ALTER TABLE .. ADD COLUMN should have a
different interpretation of what the rowtype means than the rest of
the system.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2011-01-26 16:03:24 pgsql: In pg_test_fsync, use K(1024) rather than k(1000) for write size
Previous Message Tom Lane 2011-01-26 15:36:01 Re: [COMMITTERS] pgsql: Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Broersma 2011-01-26 15:48:36 Re: [HACKERS] Seeking Mentors for Funded Reviewers
Previous Message Dimitri Fontaine 2011-01-26 15:39:38 Re: Extensions support for pg_dump, patch v27