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/