Обсуждение: Shall we just get rid of plpgsql's RENAME?

Поиск
Список
Период
Сортировка

Shall we just get rid of plpgsql's RENAME?

От
Tom Lane
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
"David E. Wheeler"
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Craig Ringer
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Stefan Kaltenbrunner
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Greg Stark
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Roberto Mello
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Dimitri Fontaine
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Tom Lane
Дата:
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


Re: Shall we just get rid of plpgsql's RENAME?

От
Jan Wieck
Дата:
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