Skip site navigation (1) Skip section navigation (2)

Re: function_name.parameter_name

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: function_name.parameter_name
Date: 2010-09-08 21:41:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Robert Haas wrote:
> On Sep 8, 2010, at 3:17 PM, Darren Duncan <darren(at)darrenduncan(dot)net> wrote:
>> Bruce Momjian wrote:
>>> Sergey Konoplev wrote:
>>>> 3.
>>>> CREATE FUNCTION func_very_very_very_very_long_name() RETURNS integer AS $$
>>>> << func_alias >>
>>>>    var_name text := 'bla';
>>>> BEGIN
>>>>    RAISE INFO '%', func_alias.var_name;
>>>> ...
>> I suggest that it might be reasonable to introduce a new syntax, that isn't already valid for something inside a routine, and use that as a terse way to reference the current function and/or its parameters.  This may best be a simple constant syntax.
> This has been proposed in the past and Tom has rejected it, but I agree that it would be useful.  The key word in this proposal is "terse".


In fact I'm not particularly enamored with my ".foo" example suggestion because 
I would actually prefer for that particular syntax to be left unused and 
available for other possible future uses that are better thought out.

I think instead that something akin to an explicit alias would both be more 
future-proofed and be the least surprising to existing users, as per #3.  If the 
alias was very short, then we have something terse for usage.

I should also say that this subject has some bearing on the topic of aliases or 
synonyms in general.  In the situations where one wants an entity to be 
referenceable by more than one name, and knows this at the time of declaring 
said entity, there could be a syntax for declaring the extra names inline with 
the original.

For example, if it wouldn't conflict with anything, one could use the "|" symbol 
(mnemonic is that means "alternation" in regular expressions) like this:

   CREATE FUNCTION func_very_very_very_very_long_name|short_name() ...

... but this could use some work since I also see that being useful for 
declaring synonyms inline, which are public names like the original, not just 
internal private names.  When used for synonyms, this would still be represented 
in the system catalog as a function named func_very... and a synonym named 
short_name, this synonym being akin to a Unix soft link or a C symbolic alias in 

Similarly, and mainly for use with named argument syntax, a named parameter 
could have several names it could go by, declared with | also.  Example:

   CREATE FUNCTION func_name(arg_name|altnm text) ...

It doesn't have to be that syntax, but I demonstrated a principle, and I 
personally like "|" for the mnemonic.

-- Darren Duncan

In response to


pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2010-09-08 22:08:26
Subject: Re: function_name.parameter_name
Previous:From: Robert HaasDate: 2010-09-08 21:09:22
Subject: Re: function_name.parameter_name

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group