Re: mixed, named notation support

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Steve Prentice <prentice(at)cisco(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: mixed, named notation support
Date: 2009-08-05 03:28:55
Message-ID: 162867790908042028x24616ed8me142c66ba61597c5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/8/5 Bernd Helmle <mailings(at)oopsware(dot)de>:
>
>
> --On 4. August 2009 20:22:05 +0200 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2009-08-05 03:34:37 Re: the case for machine-readable error fields
Previous Message Alvaro Herrera 2009-08-05 03:14:24 Re: Alpha releases: How to tag