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 16:33:12
Message-ID: AANLkTikZt0OfATUwb3YYafUYYsWJYUuLSVAA62kHnSG9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Wed, Jan 26, 2011 at 11:05 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Wed, Jan 26, 2011 at 10:36 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> 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.
>
> No, *your* interpretation is untenable.  The sequence of operations that
> the previous coding allowed behaves the same for both the table and
> rowtype instances.  The "shortcut" doesn't behave the same.

By that logic, the following sequence out to be disallowed also:

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=# alter table foo alter column a set not null;
ALTER TABLE

> This was, I believe, discussed at length when the previous coding was
> put in.  The fact that you and Noah haven't read the spec carefully
> doesn't give you license to change it.

It's certainly not obvious from the archives from around 2004-06-06
that this was discussed. Perhaps you could be a bit more specific.
As for the spec, if it requires composite types to have defaults (or
constraints), then we're in violation of that all over the place
anyway.

--
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 Tom Lane 2011-01-26 16:47:39 Re: [COMMITTERS] pgsql: Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.
Previous Message Tom Lane 2011-01-26 16:05:32 Re: [COMMITTERS] pgsql: Remove arbitrary ALTER TABLE .. ADD COLUMN restriction.

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2011-01-26 16:37:12 Re: Caution when removing git branches
Previous Message Martijn van Oosterhout 2011-01-26 16:32:35 Re: Caution when removing git branches