Re: improvise callbacks in plpgsql - Mailing list pgsql-performance

From Tom Lane
Subject Re: improvise callbacks in plpgsql
Date
Msg-id 28343.1130880562@sss.pgh.pa.us
Whole thread Raw
In response to improvise callbacks in plpgsql  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
List pgsql-performance
"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:
> A simplified idealized version of what I would like to do is
>     begin
>           select (callback_routine)(record_type)
>     end;
> from within a plpgsql function.  I am borrowing the C syntax for a
> function pointer here.

Well, there's no function pointer type in SQL :-(.  I don't see any way
to do what you want in pure plpgsql.  If you're willing to implement an
auxiliary C function you could probably make it go:

    create function callit(oid, record) returns void ...

where the OID has to be the OID of a function taking a record-type
argument.  The regprocedure pseudotype would allow you not to need
to write any numeric OIDs in your code:

    select callit('myfunc(record)'::regprocedure, recordvar);

The body of callit() need be little more than OidFunctionCall1()
plus whatever error checking and security checking you want to
include.

            regards, tom lane

pgsql-performance by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: solutions for new Postgresql application testing
Next
From: "Merlin Moncure"
Date:
Subject: Re: improvise callbacks in plpgsql