Re: Problem with Numerics multiplication in C-function

From: Ilya Urikh <ilya(dot)urikh(at)gmail(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 22:18:41
Message-ID: adf175f70908031518t29ceba0fr18116e82e931903c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 I
had started to work with PostgreSQL I was very surprised at so clear and
structured documentation. :)

On Tue, Aug 4, 2009 at 1:44 AM, Martijn van Oosterhout <kleptog(at)svana(dot)org>wrote:

> On Mon, Aug 03, 2009 at 10:20:36AM -0400, Tom Lane wrote:
> > 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.
>
> 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(at)svana(dot)org> http://svana.org/kleptog/
> > Please line up in a tree and maintain the heap invariant while
> > boarding. Thank you for flying nlogn airlines.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFKdvezIB7bNG8LQkwRAiwGAJ0dyrP+JROL9F/OhKvzLlR5O2h4tACdEIAE
> QvCDFfLfnzCpkti8PXcVp38=
> =ZXiG
> -----END PGP SIGNATURE-----
>
>

--
Best regards,
Ilya Urikh.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2009-08-03 22:45:26 Re: character 0xe29986 of encoding "UTF8" has no equivalent in "LATIN2"
Previous Message Andreas Kalsch 2009-08-03 20:46:01 Re: character 0xe29986 of encoding "UTF8" has no equivalent in "LATIN2"