Re: Executing SQL expression from C-functions

From: Jorge Arévalo <jorge(dot)arevalo(at)deimos-space(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Executing SQL expression from C-functions
Date: 2011-01-28 11:55:16
Message-ID: AANLkTimXAcAMnKzUrE8ELWB0ThHBK+bgMZbLNx9Es3NV@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2011/1/28 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> Hello
>
> see SPI interface
>
> http://www.postgresql.org/docs/8.4/interactive/spi-examples.html
>
> Regards
>
> Pavel Stehule
>

Hi Pavel,

Thanks a lot!

Best regards,
--
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge(dot)arevalo(at)deimos-space(dot)com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com
http://geohash.org/ezjqgrgzz0g

> 2011/1/28 Jorge Arévalo <jorge(dot)arevalo(at)deimos-space(dot)com>:
>> 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(dot)arevalo(at)deimos-space(dot)com
>> http://mobility.grupodeimos.com/
>> http://gis4free.wordpress.com
>> http://geohash.org/ezjqgrgzz0g
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general
>>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2011-01-28 12:47:16 Re: How best to load modules?
Previous Message Pavel Stehule 2011-01-28 11:42:54 Re: Executing SQL expression from C-functions