Re: Calling variadic function with default value in named notation

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Calling variadic function with default value in named notation
Дата
Msg-id 1449498.1603919899@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Calling variadic function with default value in named notation  (Wolfgang Walther <walther@technowledgy.de>)
Ответы Re: Calling variadic function with default value in named notation  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Calling variadic function with default value in named notation  (Wolfgang Walther <walther@technowledgy.de>)
Список pgsql-bugs
Wolfgang Walther <walther@technowledgy.de> writes:
> create function b(x int, variadic y int[] default '{}')
> returns void language sql as '';

> select b(x=>1, variadic y=>'{2}');
> [ ok ]

> select b(x=>1);
> ERROR: function b(x => integer) does not exist

> I could not find anything in the documentation that points this out as a 
> limitation, so I expected this to work. Did I miss anything?

You can't write positional arguments after named arguments, so the
failure to match isn't all that surprising; that is, to accept this
call we'd have to interpret it as a named argument and then an empty
list of things to match positionally to the variadic parameter.
Perhaps a better error message could be wished for, but given the
current rules this can't succeed.

One could imagine saying that if the function has a variadic last
parameter, then we can match that to zero or more positional arguments
after the last named argument.  Not sure that that would be a good
idea though, or how hard it'd be to implement.  It'd be a pretty
radical departure from the rules for non-variadic functions.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Wolfgang Walther
Дата:
Сообщение: Calling variadic function with default value in named notation
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Calling variadic function with default value in named notation