Re: Variadic parameters vs parameter defaults - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Variadic parameters vs parameter defaults
Date
Msg-id 200812171945.29674.peter_e@gmx.net
Whole thread Raw
In response to Re: Variadic parameters vs parameter defaults  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wednesday 17 December 2008 06:03:06 Tom Lane wrote:
> "Brendan Jurd" <direvus@gmail.com> writes:
> > So if I had these two functions ...
> >
> > var1(a int, b variadic int[])
> > var2(a int, b variadic anyarray)
> >
> > ... it would be okay to write var1(8), which resolves as var1(8,
> > array[]::int[]).  But if I tried to write var2(8) I'd get an error.
> > Maybe something like "cannot determine type of missing variadic
> > arguments".
>
> Well, we could unify these behaviors if we insisted on an explicit
> default to omit the argument in both cases.
>
>     var1(a int, b variadic int[] default '{}'::int[])
>     var2(a int, b variadic anyarray default '{}'::text[]) -- perhaps

I would just pass an empty array if the type is clear and error out otherwise.  
Mixing these things up makes things a lot more complicated for even normal 
uses.


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Variadic parameters vs parameter defaults
Next
From: Peter Eisentraut
Date:
Subject: Re: Variadic parameters vs parameter defaults