Re: Variadic polymorpic functions

From: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Variadic polymorpic functions
Date: 2010-01-22 18:43:27
Message-ID: 3eff28921001221043x564f5e45o7de0c1bfa947614f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/1/22 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it> writes:
>> 2010/1/22 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it> writes:
>>>> So there's no way to have a function accepting a VARIADIC ANY. Right?
>>>
>>> Not in PL functions.  You can do it in C if you're desperate (but you
>>> then have to deal with each argument individually --- they're not formed
>>> into an array).
>
>> How would then be declared such a function with the body written in C?
>
> I think "variadic any" is exactly it, but too lazy to go look.

I fear there's no way!

tmp1=# CREATE FUNCTION q( fmt text, variadic args any )
RETURNS void
LANGUAGE plpgsql
AS $function$
declare
begin
end;
$function$;

ERROR: syntax error at or near "any"
LINE 1: CREATE FUNCTION q( fmt text, variadic args any )
^
tmp1=# CREATE FUNCTION q( fmt text, variadic args anyelement )
RETURNS void
LANGUAGE plpgsql
AS $function$
declare
begin
end;
$function$;

ERROR: VARIADIC parameter must be an array
#

--
Vincenzo Romano
NotOrAnd Information Technologies
NON QVIETIS MARIBVS NAVTA PERITVS

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-01-22 18:46:06 Re: Variadic polymorpic functions
Previous Message Alban Hertroys 2010-01-22 18:40:04 Re: DDL question