Re: Typed tables

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Typed tables
Date: 2010-01-12 14:36:33
Message-ID: 4B4C88F1.1050207@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On tis, 2010-01-12 at 08:05 -0500, Andrew Chernow wrote:
>> In practice, tables can be used for passing data around or storing it on disk.
>> So, I guess my question remains unanswered as to what the composite type offers
>> that a table doesn't; other than a name that better suits the task.
>
> The arguments of functions are types, not tables. So you need types if
> you want to use functions.

really....

create table mytype_t (a int, b int);

create function mytype_func(t mytype_t) returns int as
$$
select ($1).a + ($1).b;
$$ language sql;

select mytype_func((10, 10)::mytype_t);

mytype_func
-------------
20
(1 row)

A table is a record type (backend/util/adt/rowtypes.c) as is a
composite. One difference is pg_class.relkind is 'r' for relation vs.
'c' for composite.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-01-12 14:39:50 Re: Streaming replication status
Previous Message Peter Eisentraut 2010-01-12 14:35:29 Re: pg_dump sort order for functions