Re: Functions returning complex types.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Thomas Hallgren" <thhal(at)mailblocks(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Functions returning complex types.
Date: 2004-01-26 20:34:15
Message-ID: 14875.1075149255@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Thomas Hallgren" <thhal(at)mailblocks(dot)com> writes:
> ... exactly the same TupleTableSlot* that is passed into my
> printMyComplextType function. This is of course extremely bad since the
> MemoryContext where it was allocated has gone out of scope (I guess, since
> this is another call).

I don't think so; unless you are hacking memory contexts internally to
your function. Here's some empirical proof that the function call
mechanism is not broken:

regression=# create type mytype as (f1 int ,f2 int);
CREATE TYPE
regression=# create function obtaintype(int,int) returns mytype as
regression-# 'select $1,$2' language sql;
CREATE FUNCTION
regression=# select * from obtaintype(1,2);
f1 | f2
----+----
1 | 2
(1 row)

regression=# create function usetype(mytype) returns int as
regression-# 'select $1.f1 + $1.f2' language sql;
CREATE FUNCTION
regression=# select usetype(obtaintype(1,2));
usetype
---------
3
(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hamedany, Allen 2004-01-26 20:55:39 Can not always connect to postmaster. Sometimes get "Connection refused".
Previous Message Thomas Hallgren 2004-01-26 20:04:16 Re: Functions returning complex types.