Re: Typed tables

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed tables
Date: 2009-11-05 23:31:33
Message-ID: 4AF36055.1040701@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Merlin Moncure wrote:
> On Thu, Nov 5, 2009 at 12:24 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> I'm planning to work on typed tables support. The idea is that you
>> create a table out of a composite type (as opposed to the other way
>> around, which is currently done automatically).
>>
>> CREATE TYPE persons_type AS (name text, bdate date);
>>
>> CREATE TABLE persons OF persons_type;
>>
>> Or the fancy version:
>>
>> CREATE TABLE persons OF persons_type ( PRIMARY KEY (name) );
>
> I use composite types (via tables) all the time but I never use
> 'create type as'...because by doing so you lose the ability to alter
> the type with 'alter table'.
>
> Am I correct that I could use your idea to make this possible (albeit
> quite ugly) by:
>
> create type foo(a text, b text);
> create table foo of foo;
> alter table foo add column c text;
> drop table foo; -- does this drop the type as well??

That seems weird. Seems we should forbid that, and have an ALTER TYPE
command instead. I guess that means that we have to somehow memorize
that the type and the table are distinct. Also, if you create a type and
a table from it, pg_dump still needs to dump the CREATE TYPE command,
not just CREATE TABLE.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Itagaki Takahiro 2009-11-06 00:19:35 Re: Typed tables
Previous Message Joshua Tolley 2009-11-05 23:17:18 Re: plperl and inline functions -- first draft