Re: function returning a row

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: function returning a row
Дата
Msg-id 20050211071326.GA94372@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: function returning a row  (Kjetil Haaland <kjetil.haaland@student.uib.no>)
Список pgsql-novice
On Thu, Feb 10, 2005 at 01:16:37PM +0100, Kjetil Haaland wrote:
>
> I have tested my function some more and found out that it is while i am trying
> to return it crashes. If i use a standard type like float it works, but with
> my own type alignres it doesn't. I have used this type as return value in
> other functions before, but not in set returning functions.

I'd suggest getting a simple set-returning function working before
adding the logic in the code you posted a couple of weeks ago.  For
example, start with a function that returns a set of integers, not
the custom type.  When you get that working, modify the function
to return a set of the custom type, but don't do anything fancy --
just create an instance of the type in the simplest way possible
and stuff some test values into it.  When that works, start adding
the extra logic that you need, but do so incrementally if possible.

The idea is to start with something that you know works, then add
a little bit at a time until it's finished or it breaks.  If it
breaks, then something about the last thing you added is likely to
be the cause, so you know where to start looking.

> When returning a float value, SRF_RETURN_NEXT(funcctx, Float8GetDatum(result))
> is used. What am i supposed to use for my own type to get the datum value? I
> have tried using PointerGetDatum(result) but then the function crashes.

PointerGetDatum() works for me, at least in the tests I've done
with custom types.  Do you have a core dump?  Have you used a
debugger to get a stack trace?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Converting interval to numeric?
Следующее
От: Akbar
Дата:
Сообщение: Re: how to know this row has been referenced or not????