Re: proposal sql: labeled function params

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Subject: Re: proposal sql: labeled function params
Date: 2008-08-15 18:20:47
Message-ID: 1218824447.7387.13.camel@huvostro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2008-08-15 at 10:01 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Random googling shows me that Oracle appears to use a syntax like
> > name => value
> > This is actually a feature that I would like to see implemented soonish, so if
> > anyone has input on the possible syntax consequences, please comment.
>
> We've been over this territory before. The problem with "name => value"
> is that it requires reserving a perfectly good user-defined operator name.

We could declare, that using operator => in function argument expression
requires parenthesis : func( a => (b => c) means param a with value
expression (b => c) nad just func((b => c)) means first param with value
(b=>c)

the main use of named params is calling functions with default values,
and giving some params. there I'm more concerned about default args and
rules for finding right function in presence of functions with both
multiple args and default values for some.

create function f(a int) ...

create function f(a int, b int default 7)

create function f(text text)

and then calling f(4) - which one would it call

what about f('4')

Of course, we could also have default values without named params, and
just require keyword DEFAULT where we want default value :)

> "value AS name", on the other hand, accomplishes the same in a more
> SQL-looking fashion with no new reserved word (since AS is already
> fully reserved).

would it be more natural / SQL-like to use "value AS name" or "name AS
value" ?

-------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2008-08-15 18:25:56 Re: Automatic Client Failover
Previous Message Bruce Momjian 2008-08-15 18:02:26 Re: Parsing of pg_hba.conf and authentication inconsistencies