Shall we just get rid of plpgsql's RENAME?

Started by Tom Laneabout 16 years ago9 messages
#1Tom Lane
tgl@sss.pgh.pa.us

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

#2David E. Wheeler
david@kineticode.com
In reply to: Tom Lane (#1)
Re: Shall we just get rid of plpgsql's RENAME?

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

#3Craig Ringer
craig@postnewspapers.com.au
In reply to: Tom Lane (#1)
Re: Shall we just get rid of plpgsql's RENAME?

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

#4Stefan Kaltenbrunner
stefan@kaltenbrunner.cc
In reply to: Tom Lane (#1)
Re: Shall we just get rid of plpgsql's RENAME?

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

#5Greg Stark
gsstark@mit.edu
In reply to: Stefan Kaltenbrunner (#4)
Re: Shall we just get rid of plpgsql's RENAME?

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

#6Roberto Mello
roberto.mello@gmail.com
In reply to: Tom Lane (#1)
Re: Shall we just get rid of plpgsql's RENAME?

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

#7Dimitri Fontaine
dfontaine@hi-media.com
In reply to: Tom Lane (#1)
Re: Shall we just get rid of plpgsql's RENAME?

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

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Greg Stark (#5)
Re: Shall we just get rid of plpgsql's RENAME?

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

#9Jan Wieck
JanWieck@Yahoo.com
In reply to: Tom Lane (#8)
Re: Shall we just get rid of plpgsql's RENAME?

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