Re: CREATE TYPE - Mailing list pgsql-hackers

From Christopher Browne
Subject Re: CREATE TYPE
Date
Msg-id m3k79dmert.fsf@chvatal.cbbrowne.com
Whole thread Raw
In response to CREATE TYPE  (ivan <iv@psycho.pl>)
List pgsql-hackers
A long time ago, in a galaxy far, far away, iv@psycho.pl (ivan) wrote:
> Can you add LIKE <parent table> TO CREATE TYPE too ?  There could be
> also CREATE TYPE ble AS ( LIKE <parent_table|other_type) ); and
> CREATE TABLE ble ( LIKE <some_type> ) , and each colmnu from compose
> type will be add to table "ble" with static (NOT) NULL, and without
> defaults.
>
> what do you think ?

That seems quite INAPPROPRIATE.

In PostgreSQL, TYPEs and DOMAINs are very nearly the same thing, and a
a table is most certainly NOT a "domain."

The thing that is analagous to what you are asking about is the notion
of table inheritance, where you might have one table inherit the
fields from another.

If you want to be able to have things like NOT NULL constraints get
inherited, you would have to associate them with a DOMAIN, use the
domain to define a table, and then INHERIT from that table.

But unless you're planning to implement a fullscale "TYPE" where you
implement the various operators for storing, printing, comparing,
aggregating, and such, this just doesn't fit with what a domain/type
is about.

In the past, there has been considerable controversy as to the merits
of table inheritance in that it is NOT evident how this should work,
in theory, based on any "theory of objects."  (The last time the fight
came up, it kind of ground to a sullen halt when no one could really
agree...)
-- 
output = ("aa454" "@" "freenet.carleton.ca")
http://cbbrowne.com/info/postgresql.html
Shin: A device for finding furniture in the dark. 


pgsql-hackers by date:

Previous
From: Lamar Owen
Date:
Subject: Re: more fun with 7.3.4 RPMs
Next
From: Bruce Momjian
Date:
Subject: Re: Stuff that doesn't work yet in IPv6 patch