Re: Problem with Numerics multiplication in C-function

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:20:36
Message-ID: 16363.1249309236@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:
> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-08-03 14:25:03 Re: synchronous_commit=off doesn't always return immediately
Previous Message Chris Black 2009-08-03 07:30:31 Out of Office AutoReply: Never thought he would be able