pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: improvise callbacks in plpgsql
Date: Tue, 01 Nov 2005 16:29:22 -0500
Message-ID: <28343.1130880562@sss.pgh.pa.us> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD754@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3417DD754@Herge.rcsinc.local>

"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



view thread (10+ messages)  latest in thread

Message-ID: <28343.1130880562@sss.pgh.pa.us>
Permalink:  ../28343.1130880562@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28343.1130880562@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, merlin.moncure@rcsonline.com
  Subject: Re: improvise callbacks in plpgsql
  In-Reply-To: <28343.1130880562@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox