numeric type in user-programs (needing numeric API?)

Started by Farid Hajjialmost 25 years ago1 messagesgeneral
Jump to latest
#1Farid Hajji
farid.hajji@ob.kamp.net

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.