Re: PL/pgSQL RENAME functionality in TODOs

Поиск
Список
Период
Сортировка
От imad
Тема Re: PL/pgSQL RENAME functionality in TODOs
Дата
Msg-id 1f30b80c0702010115i6760440ei38fa91b8a3386c4c@mail.gmail.com
обсуждение исходный текст
Ответ на Re: PL/pgSQL RENAME functionality in TODOs  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 2/1/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> imad <immaad@gmail.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Zeugswetter Andreas ADI SD"
Дата:
Сообщение: Re: "May", "can", "might"
Следующее
От: "Jignesh K. Shah"
Дата:
Сообщение: Re: fixing Makefile.shlib for solaris/gcc with -m64 flag