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

From Tom Lane
Subject Re: Problem with Numerics multiplication in C-function
Date
Msg-id 16363.1249309236@sss.pgh.pa.us
Whole thread Raw
In response to Re: Problem with Numerics multiplication in C-function  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Problem with Numerics multiplication in C-function
List pgsql-general
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.

My guess is that the reason the function appeared to work (most of the
time) before is that it wasn't being tested in an assert-enabled build.
CLOBBER_FREED_MEMORY is exposing the mistake.

            regards, tom lane

pgsql-general by date:

Previous
From: "Chris Black"
Date:
Subject: Out of Office AutoReply: Never thought he would be able
Next
From: Merlin Moncure
Date:
Subject: Re: synchronous_commit=off doesn't always return immediately