numeric type in user-programs (needing numeric API?) - Mailing list pgsql-general

From Farid Hajji
Subject numeric type in user-programs (needing numeric API?)
Date
Msg-id 200106111846.f5BIk2U02937@suse-1.meta.net
Whole thread Raw
List pgsql-general
What is the canonical way to do arithmetic computations in a user-program
using the 'numeric' datatype but _without_ using SQL numeric_*() functions
by calling the server?

Sure, an appropriate SQL statement like
  "SELECT numeric_<whatever>(<args>);"
would do the job, but I'd like to avoid calling the server for every
single computation here. Look at that long path:

 Internal format -> ascii -> libecpg -> libpq -> <network> -> postmaster
                 <-       <-         <-       <-           <-

What I'm looking for is a substitution to Informix' ESQL/C's
dec_t datatype and related dec*() API <decimal.h>, for use in
ecpg(1). I didn't find any clue in <libpq-fe.h> either.

I'm thinking about using GNU's MP-Library (mpf_t), but
that looks even uglier than "borrowing" the numeric arith.
functions directly from PG's sources:
  postgresql-7.1.2/src/backend/utils/adt/numeric.c

The best way would be to expose such functions in a public
API/library, so they can be used without server intervention.

Any ideas or workarounds?

Thanks,

-Farid.

--
Farid Hajji -- Unix Systems and Network Admin | Phone: +49-2131-67-555
Broicherdorfstr. 83, D-41564 Kaarst, Germany  | farid.hajji@ob.kamp.net
- - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - -
One OS To Rule Them All And In The Darkness Bind Them... --Bill Gates.


pgsql-general by date:

Previous
From: "Tim Barnard"
Date:
Subject: Odd behavior with LIKE?
Next
From: GH
Date:
Subject: Re: Odd behavior with LIKE?