Re: Dynamic function execution?

From: Nick Johnson <arachnid(at)notdot(dot)net>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: "Michael Fuhr" <mike(at)fuhr(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Dynamic function execution?
Date: 2006-03-15 03:17:48
Message-ID: 693AEAED-62B9-4644-BEEB-18AC608B5E31@notdot.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 14/03/2006, at 6:52 PM, Merlin Moncure wrote:

> to the original poster...it's probably possible. one way would be to
> sanity check pg_proc on the C side (at the least, check the # args).
> there might be better/faster ways though

I just finished an implementation based on the suggestions of Michael
Fuhr. My function retrieves system cache records for itself and the
function it's being asked to call, then ensures the return types and
all the argument types match. If that test is passed, it modifies its
own fcinfo struct into the one required to call the function the user
really wants, then calls FunctionCallInvoke to call it.

With this method, on the PGSQL end, you can CREATE FUNCTION with any
arbitrary parameters and return type as long as the first parameter
is oid, regproc, or regprocedure, and then call any function with a
matching signature using the defined function.

Still not done (and won't be done, unless I develop a need or someone
else wants it ) is determining when function calls are compatible
even though they're not identical (eg, through use of polymorphic
functions and ANYELEMENT/ANYARRAY).

-Nick Johnson

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paulo Henrique Oliveira 2006-03-15 03:56:21 Error in Postgresql after a Machine Crash
Previous Message John DeSoi 2006-03-15 03:10:27 Re: â in text field