Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group