Re: Access to current database from C-language function

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, Achim Domma <domma(at)procoders(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Access to current database from C-language function
Date: 2011-08-01 19:37:22
Message-ID: CAHyXU0yccKpAmnp9Q+vZn-0wNLEEhLrDFn8O0qQv4aEG=MvPug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 1, 2011 at 10:18 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Aug 1, 2011 at 11:04 AM, David Fetter <david(at)fetter(dot)org> wrote:
>> SQL is Turing-complete, so the chances are excellent that it's
>> possible to express that algorithm in it. ;)
>>
>> Look into common table expressions for iteration/recursion, and
>> windowing functions, commonly used for time series.
>>
>> http://www.postgresql.org/docs/current/static/queries-with.html
>> http://www.postgresql.org/docs/current/static/tutorial-window.html
>
> That doesn't guarantee that it can be expressed efficiently, though.
> I think the OP may be going overboard by trying to bypass SPI, but
> putting the logic inside the server seems like it could well be
> worthwhile.

I think David is probably right and this can be handled in pure sql
simply and easily (perhaps in a function, perhaps not). The SPI
interface is great, but the sql and plpgsql languages are very
powerful and should always be preferred over a C solution all else
being equal.

merlin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2011-08-01 19:48:07 Re: Compressing the AFTER TRIGGER queue
Previous Message Tom Lane 2011-08-01 18:56:57 Re: Compressing the AFTER TRIGGER queue