Re: Dynamic function execution? - Mailing list pgsql-general

From Nick Johnson
Subject Re: Dynamic function execution?
Date
Msg-id 693AEAED-62B9-4644-BEEB-18AC608B5E31@notdot.net
Whole thread Raw
In response to Re: Dynamic function execution?  ("Merlin Moncure" <mmoncure@gmail.com>)
List 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

pgsql-general by date:

Previous
From: John DeSoi
Date:
Subject: Re: â in text field
Next
From: "Paulo Henrique Oliveira"
Date:
Subject: Error in Postgresql after a Machine Crash