Re: Variable number of arguments in C language function.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daryl Tester <Daryl(dot)Tester(at)iocane(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Variable number of arguments in C language function.
Date: 2002-03-30 00:57:45
Message-ID: 29355.1017449865@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Daryl Tester <Daryl(dot)Tester(at)iocane(dot)com(dot)au> writes:
> 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 isn't any support for variable numbers of arguments; you're just
going to have to make N pg_proc entries pointing at the same C function.

> There is a comment in the FmgrInfo structure
> in include/fmgr.h about fn_nargs stating "or -1 if variable arg",

That's merely a note about a possible future expansion...

> 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,

Nope, you won't. PG is not designed for weakly typed functions;
I doubt it's possible to make this work at all.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daryl Tester 2002-03-30 02:40:56 Re: Variable number of arguments in C language function.
Previous Message Daryl Tester 2002-03-30 00:20:35 Variable number of arguments in C language function.