Re: mixed, named notation support

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: mixed, named notation support
Дата
Msg-id 162867790908042028x24616ed8me142c66ba61597c5@mail.gmail.com
обсуждение исходный текст
Ответ на Re: mixed, named notation support  (Bernd Helmle <mailings@oopsware.de>)
Ответы Re: mixed, named notation support  (Bernd Helmle <mailings@oopsware.de>)
Список pgsql-hackers
2009/8/5 Bernd Helmle <mailings@oopsware.de>:
>
>
> --On 4. August 2009 20:22:05 +0200 Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>
>> Named notation has different algorithm for function detection then
>> positional notation. There are not exist variadic parameters (because
>> these parameters hasn't individual names). So only "packed" variadic
>> parameter should be there, and this parameter have to be named  - so
>> keyword VARIADIC is optional.
>
> I wonder wether it wouldn't better to force positional notation for such
> functions then. I found it surprising that this works at all, but of course,
> someone else might enjoy this as a cool feature. To me, it feels strange and
> confusing that a function declared as VARIADIC suddenly accepts a "sloppy"
> argument only because you are using some other calling notation where others
> enforces you to use an additional keyword to match the function.
>

it's little bit difficult - notation is known from code, and isn't
possible change it..

> At least, we need to document that both notations behaves different in this
> case.

+1

some like - when notation or mixed notation are used, then variadic
parameters are disabled besause individual variadic parameters hasn't
name. You can put packed value to variadic parameter (when this
parameter is named) without keyword VARIADIC (against to positional
notation) - sample

CREATE OR REPLACE FUNCTION foo(a varchar, variadic b varchar[])
RETURNS varchar AS $$ SELECT a || ' ' || array_to_string(ARRAY(unnest b),' ')
$$ LANGUAGE sql;

SELECT foo('Hello', 'World','again'); -- positional notation
SELECT foo('Hello', VARIADIC ARRAY['World','again']) -- positional
notation with packed variadic parameter
SELECT foo('Hello', ARRAY['World','again'] AS b) -- mixed notation
with named packed variadic parameter

Pavel


>
>
>
> --
> Thanks
>
>        Bernd
>


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Alpha releases: How to tag
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: the case for machine-readable error fields