Re: Functions returning complex types.

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Re: Functions returning complex types.
Дата
Msg-id bv3rrk$2uv1$1@news.hub.org
обсуждение исходный текст
Ответ на Functions returning complex types.  ("Thomas Hallgren" <thhal@mailblocks.com>)
Ответы Re: Functions returning complex types.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@sss.pgh.pa.us> wrote in message
news:8715.1075138866@sss.pgh.pa.us...
> "Thomas Hallgren" <thhal@mailblocks.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
>




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Named arguments in function calls
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Functions returning complex types.