Re: ALTER composite type does not work, but ALTER TABLE which ROWTYPE is used as a type - works fine

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: dmitry(at)koterov(dot)ru
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER composite type does not work, but ALTER TABLE which ROWTYPE is used as a type - works fine
Date: 2008-12-08 00:57:48
Message-ID: 200812080057.mB80vm420551@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dmitry Koterov wrote:
> Could you please say, if ALTER TYPE ... ADD COLUMN is planned for a future
> PostgreSQL version?

It is not currently on the TODO list.

---------------------------------------------------------------------------

>
>
> On Fri, Dec 5, 2008 at 4:08 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>
> > On Thu, Dec 4, 2008 at 9:53 AM, Dmitry Koterov <dmitry(at)koterov(dot)ru> wrote:
> > > Hello.
> > >
> > > I can successfully ALTER a NON-EMPTY table (ct) which ROWTYPE is used as
> > a
> > > column type for another table (dt):
> > >
> > > CREATE TABLE ct (id INTEGER);
> > > CREATE TABLE dt (id INTEGER, c ct);
> > >
> > > INSERT INTO dt VALUES(1, '(666)');
> > > SELECT * FROM dt;
> > > -- (1, '(666)')
> > >
> > > ALTER TABLE ct ADD COLUMN n INTEGER;
> > > SELECT * FROM dt;
> > > -- (1, '(666,)')
> > >
> > > You see, '(666,)' means that the new field is added successfully.
> > >
> > >
> > > But, if I declare ct as a COMPOSITE type (not a table), it is not
> > permitted
> > > to ALTER this type (Postgres says that there are dependensies on ct).
> > > Why?
> >
> > Because of this there is no reason to ever use 'create type'....always
> > use 'create table'. 'alter type' can't add/remove columns anyways.
> >
> > merlin
> >
> > --
> > Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgsql-hackers
> >

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2008-12-08 01:37:09 Re: Updates of SE-PostgreSQL 8.4devel patches (r1268)
Previous Message Tom Lane 2008-12-08 00:17:25 Re: Assertion failure in new outer/semi/anti join code