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

From: Farid Hajji <farid(dot)hajji(at)ob(dot)kamp(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: numeric type in user-programs (needing numeric API?)
Date: 2001-06-11 18:46:02
Message-ID: 200106111846.f5BIk2U02937@suse-1.meta.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)hajji(at)ob(dot)kamp(dot)net
- - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - -
One OS To Rule Them All And In The Darkness Bind Them... --Bill Gates.

Browse pgsql-general by date

  From Date Subject
Next Message GH 2001-06-11 19:23:02 Re: Odd behavior with LIKE?
Previous Message Jonathan Bartlett 2001-06-11 18:02:50 Re: Variables in Postgresql