From: | Nick Johnson <arachnid(at)notdot(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Dynamic function execution? |
Date: | 2006-03-14 15:21:51 |
Message-ID: | 998B3572-AE18-476D-9453-FBEDD0A440A2@notdot.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 14/03/2006, at 12:05 AM, Michael Fuhr wrote:
> On Mon, Mar 13, 2006 at 10:45:47PM -0800, Nick Johnson wrote:
>
>> Can anyone provide me with some direction on how to write a function
>> I can load into postgres that will execute a function specified by
>> OID (or regproc/regprocedure) at runtime, with type safety? I've been
>> able to write such a function in C, but I was unable to figure out
>> how to determine the parameters that the specified function expects,
>> so I can prevent calling a function that doesn't match the expected
>> signature (which segfaults postgres).
>>
>
> Does the calling function have to be written in C? In PL/pgSQL you
> could easily query pg_proc with the oid to get the called function's
> name, argument types, etc., then build an appropriate string to
> EXECUTE.
I considered this, but I'd rather not do it by string manipulation
and dynamic SQL - it seems a kludge.
> In C you could use SearchSysCache() and SysCacheGetAttr();
> search through the source code for examples of calls to those
> functions with a first argument of PROCOID.
Thanks for the tips.
>
> Why do you need to do this? What problem are you trying to solve?
>
I want to associate Postgres functions with rows of a table (eg, a
table column of datatype regproc or regprocedure) and be able to
execute the function associated with that row in a query.
-Nick Johnson
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-03-14 16:21:21 | Re: [GENERAL] Transaction eating up all RAM |
Previous Message | Bryan White | 2006-03-14 14:54:51 | Resetting priveleges on a table |