X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B7F96DB735 for ; Tue, 1 Nov 2005 17:29:22 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44368-02 for ; Tue, 1 Nov 2005 21:29:20 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4F359DB733 for ; Tue, 1 Nov 2005 17:29:21 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jA1LTNle028344; Tue, 1 Nov 2005 16:29:23 -0500 (EST) To: "Merlin Moncure" Cc: pgsql-performance@postgresql.org Subject: Re: improvise callbacks in plpgsql In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3417DD754@Herge.rcsinc.local> References: <6EE64EF3AB31D5448D0007DD34EEB3417DD754@Herge.rcsinc.local> Comments: In-reply-to "Merlin Moncure" message dated "Tue, 01 Nov 2005 14:00:00 -0500" Date: Tue, 01 Nov 2005 16:29:22 -0500 Message-ID: <28343.1130880562@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006] X-Spam-Score: 0.006 X-Spam-Level: X-Archive-Number: 200511/13 X-Sequence-Number: 15270 "Merlin Moncure" 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