Search Postgresql Archives

Re: Problem with Numerics multiplication in C-function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martijn van Oosterhout <kleptog@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux