manipulating NUMERIC values in C extension - Mailing list pgsql-general

From Geoff Winkless
Subject manipulating NUMERIC values in C extension
Date
Msg-id CAEzk6feVfZJVGTdWqsX5WoDGXmZzUKVa9FBrireE9_Cmkz2ifA@mail.gmail.com
Whole thread Raw
Responses Re: manipulating NUMERIC values in C extension  (John McKown <john.archie.mckown@gmail.com>)
Re: manipulating NUMERIC values in C extension  (Geoff Winkless <pgsqladmin@geoff.dj>)
List pgsql-general
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,

Geoff


pgsql-general by date:

Previous
From: "Jonathan S. Katz"
Date:
Subject: Re: Code of Conduct plan
Next
From: John McKown
Date:
Subject: Re: manipulating NUMERIC values in C extension