Skip site navigation (1) Skip section navigation (2)

Re: ALTER TYPE recursion to typed tables

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TYPE recursion to typed tables
Date: 2010-11-02 17:54:51
Message-ID: AANLkTinvJ7MzJWawk=X_bJzwo7Xkku44q-xipcOuYnpE@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Tue, Nov 2, 2010 at 9:15 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> I'm working on propagating ALTER TYPE commands to typed tables.  This is
> currently prohibited.  For example, take these regression test cases:
>
> CREATE TYPE test_type2 AS (a int, b text);
> CREATE TABLE test_tbl2 OF test_type2;
> ALTER TYPE test_type2 ADD ATTRIBUTE c text; -- fails
> ALTER TYPE test_type2 ALTER ATTRIBUTE b TYPE varchar; -- fails
> ALTER TYPE test_type2 DROP ATTRIBUTE b; -- fails
> ALTER TYPE test_type2 RENAME ATTRIBUTE b TO bb; -- fails
>
> The actual implementation isn't very difficult, because the ALTER TABLE
> code already knows everything about recursion.
>
> Now I'm wondering what kind of syntax should be used to control this.  I
> think you don't want to automatically propagate such innocent looking
> operations to tables in a potentially data-destroying manner.  The
> natural idea would be RESTRICT/CASCADE.  This is currently only
> associated with DROP operations, but I suppose ADD/ALTER/RENAME
> ATTRIBUTE x ... CASCADE doesn't sound too odd.
>
> Comments, other ideas?

That seems reasonable.  What do you plan to do about this case?

CREATE TYPE test_type AS (a int, b text);
CREATE TABLE test_tbl (x test_type);
ALTER TYPE test_type ADD ATTRIBUTE c text;

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

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-11-02 17:57:26
Subject: Re: create custom collation from case insensitive portuguese
Previous:From: Kevin GrittnerDate: 2010-11-02 17:33:15
Subject: Re: [PATCH] V3: Idle in transaction cancellation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group