Re: Problem with Numerics multiplication in C-function - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Problem with Numerics multiplication in C-function
Date
Msg-id 20090803144403.GA7352@svana.org
Whole thread Raw
In response to Re: Problem with Numerics multiplication in C-function  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Problem with Numerics multiplication in C-function
Re: Problem with Numerics multiplication in C-function
List pgsql-general
On Mon, Aug 03, 2009 at 10:20:36AM -0400, Tom Lane wrote:
> Martijn van Oosterhout <kleptog@svana.org> writes:
> > What you need to do is copy the Datum you wish to return into the upper
> > memory context. I'm not seeing a helpful SPI utility function or
> > obvious example here you help you, but I'm sure it's something with
> > MemoryContextSwitchTo() and datumCopy().
>
> 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(). It might actually be
helpful to include in the documentation an example of returning from a
function a result from SPI, since it's not entirely obvious.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: synchronous_commit=off doesn't always return immediately
Next
From: Tom Lane
Date:
Subject: Re: Problem with Numerics multiplication in C-function