Functions as first-class values - Mailing list pgsql-general

From Jon Smark
Subject Functions as first-class values
Date
Msg-id 961874.23865.qm@web112804.mail.gq1.yahoo.com
Whole thread Raw
Responses Re: Functions as first-class values
List pgsql-general
Hi,

Is there support in PL/pgSQL for treating functions as first-class values?
Consider the pseudo-code simple example below, which illustrates how this
feature can be useful.  I reckon that this behaviour can be emulated using
EXECUTE, but I suspect there are serious performance penalties.
Your thoughts?

Thanks in advance!
Jon


CREATE FUNCTION f1 (int) RETURNS boolean ...
CREATE FUNCTION f2 (int) RETURNS boolean ...
CREATE FUNCTION f3 (int) RETURNS boolean ...

CREATE FUNCTION do_stuff ...
BEGIN
        CASE cond
                WHEN 'a' THEN func := f1;
                WHEN 'b' THEN func := f2;
                WHEN 'c' THEN func := f3;
        END CASE

        SELECT * FROM foobar WHERE func (foobar.age);
END;


pgsql-general by date:

Previous
From: tv@fuzzy.cz
Date:
Subject: Re: Critical Bug
Next
From: Andrew Sullivan
Date:
Subject: Re: forums.postgresql.com.au