From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
Cc: | Ilya Urikh <ilya(dot)urikh(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with Numerics multiplication in C-function |
Date: | 2009-08-03 14:49:06 |
Message-ID: | 16795.1249310946@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> On Mon, Aug 03, 2009 at 10:20:36AM -0400, Tom Lane wrote:
>> SPI_palloc is what to use to allocate the result in the right place.
> Ofcourse, and then a memcpy(). I was distracted by the fact there is an
> SPI_copy/returntuple(), but no SPI_returndatum().
Yeah, I was just thinking that that seems like an oversight.
plpgsql does this:
if (!fcinfo->isnull && !func->fn_retbyval)
{
Size len;
void *tmp;
len = datumGetSize(estate.retval, false, func->fn_rettyplen);
tmp = SPI_palloc(len);
memcpy(tmp, DatumGetPointer(estate.retval), len);
estate.retval = PointerGetDatum(tmp);
}
but it seems like it'd be reasonable to provide SPI_datumcopy or
something like that to encapsulate this a bit more conveniently.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Gould | 2009-08-03 14:51:46 | Partition tables |
Previous Message | Martijn van Oosterhout | 2009-08-03 14:44:04 | Re: Problem with Numerics multiplication in C-function |