Re: WIP: Allow SQL-language functions to reference parameters by parameter name

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Jim Nasby <jim(at)nasby(dot)net>, Kevin Grittner <kevin(dot)grittner(at)wicourts(dot)gov>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: Allow SQL-language functions to reference parameters by parameter name
Date: 2011-04-18 16:51:12
Message-ID: BANLkTimG8Aj-2LzCgyC0v-rB8zNChkYG+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 18, 2011 at 11:33 AM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Excerpts from Robert Haas's message of lun abr 18 09:33:06 -0300 2011:
>
>> I don't much like Jim's syntax suggestion (the alias really ought to
>> be declared within the function body, I think, not added to the CREATE
>> FUNCTION statement) but I don't necessarily think it's a bad idea.
>> What would be even better, in my view, is having a short alias that is
>> defined by default, but all previous proposals in this vein have been
>> shot down by Tom and Andrew.  As a practical matter, though, I think
>> what Jim is talking about speaks to a real need - people want to make
>> SQL function names long and descriptive, but they do NOT want to spell
>> out that long function name 16 times inside the function body.
>
> plpgsql has the #option thing in functions; why can't we have something
> similar in SQL functions?
>
>  CREATE FUNCTION function_with_really_really_descriptive_name (
>   some_parameter int
>  ) RETURNS int LANGUAGE SQL AS $$
>     #option function_alias fwrrdn
>         SELECT fwrrdn.some_parameter
>  $$;
>
> Not necessarily that exact syntax.

If we are rejecting $foo on grounds of deviating from sql standard,
shouldn't this be rejected on the same grounds? There is no such
syntax in sql/psm.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mike Fowler 2011-04-18 16:52:23 Re: [JDBC] JDBC connections to 9.1
Previous Message Alvaro Herrera 2011-04-18 16:50:39 Re: Windows 64 bit warnings