Re: [GENERAL] Problem with Numerics multiplication in C-function

2009-08-03 Thread Ilya Urikh
Thank's a lot! That's really help. I failed to bear memory context switching in mind. I resolved this problem with following strings in *getRate*: result = SPI_palloc(sizeof(rate)); memcpy(result, rate, sizeof(rate)); P.S. I think it's a good idea to add example to documentation. Anyway when

Re: [GENERAL] Problem with Numerics multiplication in C-function

2009-08-03 Thread Tom Lane
Martijn van Oosterhout 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

Re: [GENERAL] Problem with Numerics multiplication in C-function

2009-08-03 Thread Martijn van Oosterhout
On Mon, Aug 03, 2009 at 10:20:36AM -0400, Tom Lane wrote: > Martijn van Oosterhout 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 somet

Re: [GENERAL] Problem with Numerics multiplication in C-function

2009-08-03 Thread Tom Lane
Martijn van Oosterhout 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 i

Re: [GENERAL] Problem with Numerics multiplication in C-function

2009-08-03 Thread Martijn van Oosterhout
On Mon, Aug 03, 2009 at 01:45:53PM +1100, Ilya Urikh wrote: > Hi, I have a strange problem with Numeric multiplication in C-function. > > There are 2 functions getRate and getVAT which return Numeric. In 3rd > function calculateService I try to multiply the results of getRate and > getVAT. After e