Re: Functions returning complex types.

From: "Thomas Hallgren" <thhal(at)mailblocks(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Functions returning complex types.
Date: 2004-01-26 20:04:16
Message-ID: bv3rrk$2uv1$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The unsupported return type was all my fault. The Form_pg_type typrelid
attribute points to the class of the relation, not the relation as such.
Duh...

But now, when I actually can return complex types, I encounter another
problem. It happens when I pass a complex type returned from one function as
a complex parameter to another function, i.e. something like:

SELECT printMyComplexType(obtainMyComplexType());

Some research shows that the TupleTableSlot* that I create in
obtainMyComplexType() using the following code:

TupleDesc tupleDesc = TypeGetTupleDesc(typeId, NIL);
TupleTableSlot* slot = TupleDescGetSlot(tupleDesc);
return TupleGetDatum(slot, tuple);

is 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). AFAICS, the way I do it is by the book. What am I
doing wrong?

Regards,

Thomas Hallgren

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote in message
news:8715(dot)1075138866(at)sss(dot)pgh(dot)pa(dot)us(dot)(dot)(dot)
> "Thomas Hallgren" <thhal(at)mailblocks(dot)com> writes:
> > I'm trying to use a function that returns a complex type. I have no
problem
> > creating the function but when I try to use it I get the message:
>
> > ERROR: function in FROM has unsupported return type
>
> AFAICS it's not possible to get that message for a function returning a
> composite type. You'd better show exactly what you did.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-01-26 20:34:15 Re: Functions returning complex types.
Previous Message Tom Lane 2004-01-26 19:48:04 Re: Named arguments in function calls