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?
In response to
pgsql-novice by date
|Next:||From: Peter Mount||Date: 2005-02-11 10:00:46|
|Previous:||From: Bruno Wolff III||Date: 2005-02-11 04:58:25|
|Subject: Re: Converting interval to numeric?|