Re: manipulating NUMERIC values in C extension

2018-06-08 Thread Geoff Winkless
On Fri, 8 Jun 2018 at 13:44, John McKown wrote: > Have you considered the standard C library functions: "atoi()", "atof()", > "atol()", and "atoll()" ? Hi John My issue wasn't so much how to get a number out of the string, rather how to get that value back into a NUMERIC object to return back t

Re: manipulating NUMERIC values in C extension

2018-06-08 Thread Geoff Winkless
On Fri, 8 Jun 2018 at 13:47, Geoff Winkless wrote: > Answering my own question, looks like And just in case anyone googling the question comes across this, this example code works. #include "postgres.h" #include #include "fmgr.h" #include "utils/geo_decls.h" #include "funcapi.h" #include "utils

Re: manipulating NUMERIC values in C extension

2018-06-08 Thread Geoff Winkless
On Fri, 8 Jun 2018 at 13:27, Geoff Winkless wrote: > 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 :( Answering my own question, looks like res = DatumGetNumeric(DirectFu

Re: manipulating NUMERIC values in C extension

2018-06-08 Thread John McKown
On Fri, Jun 8, 2018 at 7:27 AM Geoff Winkless 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 > represent

manipulating NUMERIC values in C extension

2018-06-08 Thread Geoff Winkless
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-n