Executing SQL expression from C-functions - Mailing list pgsql-general

From Jorge Arévalo
Subject Executing SQL expression from C-functions
Date
Msg-id AANLkTimNNM-AJQ9sRRQX+mnN+EVenFJs0V3UU=hgkrOx@mail.gmail.com
Whole thread Raw
Responses Re: Executing SQL expression from C-functions
List pgsql-general
Hello,

I need to write a C-function to extend my PostgreSQL server
functionality. One of the arguments of that function is a string
representing any PostgreSQL valid expression returning a number. For
example:

3+5*cos(7.4)/8
7
2+2
log(34)
degrees(0.5)
power(9.0, 3.0)
case when 8 > 2 then 1 when 7*5 < 43 then 2 else 3 end

and so on

The point is my function first replace some values in the expression
(variable names) for numbers and then it should execute the expression
and returns the result (a number). With PL/pgSQL I can use EXECUTE
expr INTO val, but how could I do it in a C function?

Many thanks in advance, and best regards

--
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge.arevalo@deimos-space.com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com
http://geohash.org/ezjqgrgzz0g

pgsql-general by date:

Previous
From: Alfredo Torres
Date:
Subject: Fwd: Fw: FW: POR FAVOR REENVIALA, NO TE TARDAS CASI NADA..!
Next
From: Alfredo Torres
Date:
Subject: Fwd: RV: RV: DECRETO (ME LLEGÓ HOY)