Thread

  1. Shall we just get rid of plpgsql's RENAME?

    Tom Lane <tgl@sss.pgh.pa.us> — 2009-11-05T01:34:02Z

    According to
    http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    the RENAME declaration in plpgsql has been known broken since PG 7.3.
    Nobody has bothered to fix it.  Shall we just rip it out?
    
    The reason I'm looking at it right now is that it's quite unclear
    what it is supposed to mean.  Consider
    
    	DECLARE x int;
    	BEGIN
    		... some stuff ...
    		DECLARE y int;
    			RENAME x to z;
    		BEGIN
    			... other stuff ...
    		END;
    		... yet more stuff ...
    	END;
    
    What effect should the RENAME have on the name of "x" as seen by the
    code outside the inner DECLARE block?  In the current implementation,
    the RENAME would change "x" to "z" as seen by the code following the
    inner block, which seems pretty unexpected.  What's worse, once we
    have support in there for re-parsing SQL queries, the RENAME could
    retroactively affect the behavior of the code before the inner block,
    which is surely unexpected.
    
    As the documentation points out, there doesn't seem to be any real
    use for RENAME that isn't served as well or better by ALIAS, so
    I'm not especially interested in trying to puzzle out what it should
    do or how to make it do that.  I want to just remove it.  Or we could
    make it an alternative spelling for ALIAS.  Comments?
    
    			regards, tom lane
    
    
  2. Re: Shall we just get rid of plpgsql's RENAME?

    David Wheeler <david@kineticode.com> — 2009-11-05T03:43:22Z

    On Nov 4, 2009, at 5:34 PM, Tom Lane wrote:
    
    > According to
    > http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    > the RENAME declaration in plpgsql has been known broken since PG 7.3.
    > Nobody has bothered to fix it.  Shall we just rip it out?
    
    +1
    
    David
    
    
  3. Re: Shall we just get rid of plpgsql's RENAME?

    Craig Ringer <craig@postnewspapers.com.au> — 2009-11-05T06:17:17Z

    On 5/11/2009 9:34 AM, Tom Lane wrote:
    > According to
    > http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    > the RENAME declaration in plpgsql has been known broken since PG 7.3.
    > Nobody has bothered to fix it.  Shall we just rip it out?
    
    I certainly wouldn't shed a tear. Off with it's head.
    
    --
    Craig Ringer
    
    
  4. Re: Shall we just get rid of plpgsql's RENAME?

    Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> — 2009-11-05T10:18:22Z

    Tom Lane wrote:
    > According to
    > http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    > the RENAME declaration in plpgsql has been known broken since PG 7.3.
    > Nobody has bothered to fix it.  Shall we just rip it out?
    
    +1 on that - I don't think I have seen it used in any production code I 
    came accross in a long time.
    
    
    Stefan
    
    
  5. Re: Shall we just get rid of plpgsql's RENAME?

    Greg Stark <gsstark@mit.edu> — 2009-11-05T11:35:34Z

    On Thu, Nov 5, 2009 at 10:18 AM, Stefan Kaltenbrunner
    <stefan@kaltenbrunner.cc> wrote:
    > Tom Lane wrote:
    >>
    >> According to
    >>
    >> http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    >> the RENAME declaration in plpgsql has been known broken since PG 7.3.
    >> Nobody has bothered to fix it.  Shall we just rip it out?
    >
    > +1 on that - I don't think I have seen it used in any production code I came
    > accross in a long time.
    
    I'm fine with just ripping it out. Making it an alias for ALIAS seems
    tempting at first but I can't say how often I've found constructs like
    that confusing in languages and interfaces because the natural
    assumption is that there must be some kind of distinction between the
    terms. In the long term it makes things way simpler to understand if
    there aren't redundancies like that.
    
    Did we get the keyword from anyplace? Is it an Oracleism or MSSQLism
    or anything?
    
    -- 
    greg
    
    
  6. Re: Shall we just get rid of plpgsql's RENAME?

    Roberto Mello <roberto.mello@gmail.com> — 2009-11-05T11:42:01Z

    On Wed, Nov 4, 2009 at 9:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    > According to
    > http://developer.postgresql.org/pgdocs/postgres/plpgsql-declarations.html#PLPGSQL-DECLARATION-RENAMING-VARS
    > the RENAME declaration in plpgsql has been known broken since PG 7.3.
    > Nobody has bothered to fix it.  Shall we just rip it out?
    
    +1
    
    I can't remember any production code using it, and I think making it
    an alias for ALIAS will just create confusion IMHO.
    
    Roberto
    
    
  7. Re: Shall we just get rid of plpgsql's RENAME?

    Dimitri Fontaine <dfontaine@hi-media.com> — 2009-11-05T14:51:06Z

    Hi,
    
    Tom Lane <tgl@sss.pgh.pa.us> writes:
    > 	DECLARE x int;
    > 	BEGIN
    > 		... some stuff ...
    > 		DECLARE y int;
    > 			RENAME x to z;
    > 		BEGIN
    > 			... other stuff ...
    > 		END;
    > 		... yet more stuff ...
    > 	END;
    >
    > What effect should the RENAME have on the name of "x" as seen by the
    > code outside the inner DECLARE block?
    
    None in my mind.
    
    > As the documentation points out, there doesn't seem to be any real
    > use for RENAME that isn't served as well or better by ALIAS, so
    > I'm not especially interested in trying to puzzle out what it should
    > do or how to make it do that.  I want to just remove it.  Or we could
    > make it an alternative spelling for ALIAS.  Comments?
    
    The difference I'd not be surprised to see between RENAME and ALIAS
    would be for RENAME to allow for inner blocks to reuse the renamed
    variable (x in ... other stuff ... in your example), whereas using ALIAS
    the variable just has 2 names.
    
    Does it make any sense?
    -- 
    dim
    
    
  8. Re: Shall we just get rid of plpgsql's RENAME?

    Tom Lane <tgl@sss.pgh.pa.us> — 2009-11-05T14:51:48Z

    Greg Stark <gsstark@mit.edu> writes:
    > Did we get the keyword from anyplace? Is it an Oracleism or MSSQLism
    > or anything?
    
    Hmm, that is a good question.  I had assumed it was an Oracle-ism,
    but it doesn't seem to be described anywhere in my copy of the PL/SQL
    manual (which is a bit old but newer than plpgsql...)  I dunno where
    Jan got it from.
    
    			regards, tom lane
    
    
  9. Re: Shall we just get rid of plpgsql's RENAME?

    Jan Wieck <janwieck@yahoo.com> — 2009-11-05T15:55:39Z

    On 11/5/2009 9:51 AM, Tom Lane wrote:
    > Greg Stark <gsstark@mit.edu> writes:
    >> Did we get the keyword from anyplace? Is it an Oracleism or MSSQLism
    >> or anything?
    > 
    > Hmm, that is a good question.  I had assumed it was an Oracle-ism,
    > but it doesn't seem to be described anywhere in my copy of the PL/SQL
    > manual (which is a bit old but newer than plpgsql...)  I dunno where
    > Jan got it from.
    
    And I don't remember why it was necessary or seemed like a good idea.
    
    
    Jan
    
    -- 
    Anyone who trades liberty for security deserves neither
    liberty nor security. -- Benjamin Franklin