Shall we just get rid of plpgsql's RENAME?

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 01:34:02
Message-ID: 7390.1257384842@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 03:43:22
Message-ID: 1E25F10C-6B96-4558-9706-5A4B7209199E@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 06:17:17
Message-ID: 4AF26DED.5050101@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 10:18:22
Message-ID: 4AF2A66E.30101@kaltenbrunner.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 11:35:34
Message-ID: 407d949e0911050335sa81635bt8170847f3071c708@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 5, 2009 at 10:18 AM, Stefan Kaltenbrunner
<stefan(at)kaltenbrunner(dot)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


From: Roberto Mello <roberto(dot)mello(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 11:42:01
Message-ID: 42d652c70911050342u2d012964j642b3451db6605bb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 4, 2009 at 9:34 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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


From: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 14:51:06
Message-ID: 878wel81ph.fsf@hi-media-techno.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>, pgsql-hackers(at)postgresql(dot)org, Jan Wieck <JanWieck(at)Yahoo(dot)com>
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 14:51:48
Message-ID: 20080.1257432708@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)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


From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Stefan Kaltenbrunner <stefan(at)kaltenbrunner(dot)cc>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Shall we just get rid of plpgsql's RENAME?
Date: 2009-11-05 15:55:39
Message-ID: 4AF2F57B.6090609@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/5/2009 9:51 AM, Tom Lane wrote:
> Greg Stark <gsstark(at)mit(dot)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