Variable number of arguments in C language function.
От | Daryl Tester |
---|---|
Тема | Variable number of arguments in C language function. |
Дата | |
Msg-id | 3CA504D3.BD55F3D4@iocane.com.au обсуждение исходный текст |
Ответы |
Re: Variable number of arguments in C language function.
|
Список | pgsql-general |
Hi, Under PostgreSQL 7.1.3, I'm attempting to create a 'C' language function using the V1 style interface which accepts a variable number of parameters. That part appears to work fine, in that I can retrieve the number of arguments from the fcinfo structure passed into the C function, and am able to extract the appropriate argument. What I'm attempting to do is, and coming unstuck at, is to "CREATE FUNCTION" that allows a variable number of arguments to be passed in, without having to define a seperate function in pg_proc for each argument count. There is a comment in the FmgrInfo structure in include/fmgr.h about fn_nargs stating "or -1 if variable arg", but setting pronargs to -1 for the appropriate pg_proc entry just resulted in "Function pg_exec(unknown) does not exist". My goal was to be able to pass in arguments of any type into the function and have it handle (and convert) the argument type, but (and this brainwave only occurred in the last five minutes) I suspect that I may not be able to extract the data type from Datum, and that's the reason why this typing mechanism for pg_proc exists in the first place. The ultimate aim is to create a "pg_exec" function that will allow passing in of ints, floats and strings and execve them as arguments, with the non-string arguments being converted to string equivalents. Is this achievable, or am I barking up the wrong forest? Thanks in advance. -- Regards, Daryl Tester, Software Wrangler and Bit Herder, IOCANE Pty. Ltd.
В списке pgsql-general по дате отправления: