Re: PL/pgSQL RENAME functionality in TODOs

Lists: pgsql-hackers
From: imad <immaad(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: PL/pgSQL RENAME functionality in TODOs
Date: 2007-01-30 18:59:05
Message-ID: 1f30b80c0701301059t4c418a8cyfde61cab8cae7d0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I was testing the following statement and found it working fine on
version 8.2.1.

"Fix RENAME to work on variables other than OLD/NEW"

I can rename just any variable declared in a PL block apart from
OLD/NEW. Is the TODOs list out of sync or I am missing the point here?

--Imad
www.EnterpriseDB.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: imad <immaad(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Date: 2007-01-30 21:34:17
Message-ID: 9845.1170192857@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

imad <immaad(at)gmail(dot)com> writes:
> "Fix RENAME to work on variables other than OLD/NEW"
> I can rename just any variable declared in a PL block apart from
> OLD/NEW. Is the TODOs list out of sync or I am missing the point here?

Really? It looks pretty broken to me still:

regression=# create function foo() returns int as $$
regression$# declare
regression$# x int := 1;
regression$# rename x to y;
regression$# begin
regression$# return y;
regression$# end;$$ language plpgsql;
ERROR: syntax error at or near "x"
LINE 4: rename x to y;
^

See old discussion here:
http://archives.postgresql.org/pgsql-hackers/2002-03/msg00591.php

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: imad <immaad(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Date: 2007-01-31 04:24:10
Message-ID: 200701310424.l0V4OAi20588@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


URL added to TODO. (I didn't have URLs in there at the time).

---------------------------------------------------------------------------

Tom Lane wrote:
> imad <immaad(at)gmail(dot)com> writes:
> > "Fix RENAME to work on variables other than OLD/NEW"
> > I can rename just any variable declared in a PL block apart from
> > OLD/NEW. Is the TODOs list out of sync or I am missing the point here?
>
> Really? It looks pretty broken to me still:
>
> regression=# create function foo() returns int as $$
> regression$# declare
> regression$# x int := 1;
> regression$# rename x to y;
> regression$# begin
> regression$# return y;
> regression$# end;$$ language plpgsql;
> ERROR: syntax error at or near "x"
> LINE 4: rename x to y;
> ^
>
> See old discussion here:
> http://archives.postgresql.org/pgsql-hackers/2002-03/msg00591.php
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: imad <immaad(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Date: 2007-01-31 07:15:40
Message-ID: 1f30b80c0701302315i5df8abe6s46d3aea5a3eb707c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

OK, so renaming does not work in the same block.
You can rename a vairable in a nested block and thats why it works for OLD/NEW.

BTW, what is the purpose behind it? Declaring a variable in a block
and quickly renaming it does not make sense to me.

--Imad
www.EnterpriseDB.com

On 1/31/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
> URL added to TODO. (I didn't have URLs in there at the time).
>
> ---------------------------------------------------------------------------
>
> Tom Lane wrote:
> > imad <immaad(at)gmail(dot)com> writes:
> > > "Fix RENAME to work on variables other than OLD/NEW"
> > > I can rename just any variable declared in a PL block apart from
> > > OLD/NEW. Is the TODOs list out of sync or I am missing the point here?
> >
> > Really? It looks pretty broken to me still:
> >
> > regression=# create function foo() returns int as $$
> > regression$# declare
> > regression$# x int := 1;
> > regression$# rename x to y;
> > regression$# begin
> > regression$# return y;
> > regression$# end;$$ language plpgsql;
> > ERROR: syntax error at or near "x"
> > LINE 4: rename x to y;
> > ^
> >
> > See old discussion here:
> > http://archives.postgresql.org/pgsql-hackers/2002-03/msg00591.php
> >
> > regards, tom lane
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > message can get through to the mailing list cleanly
>
> --
> Bruce Momjian bruce(at)momjian(dot)us
> EnterpriseDB http://www.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: imad <immaad(at)gmail(dot)com>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Date: 2007-02-01 00:28:25
Message-ID: 8906.1170289705@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

imad <immaad(at)gmail(dot)com> writes:
> OK, so renaming does not work in the same block.
> You can rename a vairable in a nested block and thats why it works for OLD/NEW.

> BTW, what is the purpose behind it? Declaring a variable in a block
> and quickly renaming it does not make sense to me.

I agree it's pretty useless; but if we're gonna forbid it then we should
throw a more sensible error than "syntax error".

Actually, it seems to me that it works in the nested-block case only for
rather small values of "work":

regression=# create function foo() returns int as $$
regression$# declare
regression$# x int := 1;
regression$# begin
regression$# x := 2;
regression$# declare
regression$# rename x to y;
regression$# begin
regression$# y := 3;
regression$# end;
regression$# return x;
regression$# end$$ language plpgsql;
CREATE FUNCTION
regression=# select foo();
ERROR: column "x" does not exist
LINE 1: SELECT x
^
QUERY: SELECT x
CONTEXT: PL/pgSQL function "foo" line 10 at return
regression=#

Surely the variable's name should be x again after we're out of the
nested block?

regards, tom lane


From: imad <immaad(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bruce Momjian" <bruce(at)momjian(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL RENAME functionality in TODOs
Date: 2007-02-01 09:15:19
Message-ID: 1f30b80c0702010115i6760440ei38fa91b8a3386c4c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2/1/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> imad <immaad(at)gmail(dot)com> writes:
> > OK, so renaming does not work in the same block.
> > You can rename a vairable in a nested block and thats why it works for OLD/NEW.
>
> > BTW, what is the purpose behind it? Declaring a variable in a block
> > and quickly renaming it does not make sense to me.
>
> I agree it's pretty useless; but if we're gonna forbid it then we should
> throw a more sensible error than "syntax error".
>
> Actually, it seems to me that it works in the nested-block case only for
> rather small values of "work":
>
> regression=# create function foo() returns int as $$
> regression$# declare
> regression$# x int := 1;
> regression$# begin
> regression$# x := 2;
> regression$# declare
> regression$# rename x to y;
> regression$# begin
> regression$# y := 3;
> regression$# end;
> regression$# return x;
> regression$# end$$ language plpgsql;
> CREATE FUNCTION
> regression=# select foo();
> ERROR: column "x" does not exist
> LINE 1: SELECT x
> ^
> QUERY: SELECT x
> CONTEXT: PL/pgSQL function "foo" line 10 at return
> regression=#
>
> Surely the variable's name should be x again after we're out of the
> nested block?

Yes, seems to be the only possible reason of renaming a variable.

--Imad
www.EnterpriseDB.com