From: | John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com> |
---|---|
To: | Geoff Winkless <pgsqladmin(at)geoff(dot)dj> |
Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: manipulating NUMERIC values in C extension |
Date: | 2018-06-08 12:44:25 |
Message-ID: | CAAJSdjjG=zRdJHWGoMB648MrFpukhG82dsJcWCBgUOMR_8Rj3g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Jun 8, 2018 at 7:27 AM Geoff Winkless <pgsqladmin(at)geoff(dot)dj> wrote:
> Hi
>
> I'd like to be able to perform some manipulation on NUMERIC values in
> a C function; however the exposed functionality in numeric.h is pretty
> restrictive.
>
> I can see numeric_normalize will return a pointer to a string
> representation, which is workable, and if there were an equivalent
> string-to-numeric function that would be enough (although not the most
> efficient) but I can't see a way to get a string back in to a numeric
> value to return.
>
> numeric_in looks like it might do what I want but to do that I would
> have to build a FunctionCallInfo struct to do that, and I'm not 100%
> clear how to do that either :(
>
> I _could_ return the result as a varchar and cast it back to numeric
> in the SQL, but that's not very clean.
>
> Accessing the numeric structure directly would work too but I'm
> assuming that's not recommended since it's not exposed in numeric.h.
>
> Any thoughts would be appreciated,
>
Have you considered the standard C library functions: "atoi()", "atof()",
"atol()", and "atoll()" ?
>
> Geoff
>
>
--
Rap music is performed by those that can not sing so others can not think.
Maranatha! <><
John McKown
From | Date | Subject | |
---|---|---|---|
Next Message | Geoff Winkless | 2018-06-08 12:47:49 | Re: manipulating NUMERIC values in C extension |
Previous Message | Geoff Winkless | 2018-06-08 12:27:13 | manipulating NUMERIC values in C extension |