Re: BUG #1956: Plpgsql top-level DECLARE does not share scope

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #1956: Plpgsql top-level DECLARE does not share scope
Дата
Msg-id 23735.1129224656@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #1956: Plpgsql top-level DECLARE does not share scope  ("Jim C. Nasby" <jnasby@pervasive.com>)
Ответы Re: BUG #1956: Plpgsql top-level DECLARE does not share scope  ("Jim C. Nasby" <jnasby@pervasive.com>)
Список pgsql-bugs
"Jim C. Nasby" <jnasby@pervasive.com> writes:
> Based on all that, I would certainly be in favor of throwing a warning
> if you over-define something, since 99% of the time it's a mistake. Is
> that possible with the current checking we do at compile time?

Without having looked at the code, I imagine the problem is that we
can't tell this situation from an ordinary nested DECLARE block,
that is

    declare x int;
    begin
        ...
        declare x float;
        begin
            ...

The above is legal code and I don't think we should throw a warning for
it.

Basically, DECLARE introduces a new name scope that wouldn't be there
if you didn't say DECLARE.  Without some bizarre reinterpretation of the
meaning of a DECLARE at the start of a function, variables automatically
created by plpgsql are going to be in an outer scope surrounding that of
the first DECLARE.

            regards, tom lane

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

Предыдущее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: BUG #1956: Plpgsql top-level DECLARE does not share scope
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: BUG #1815: ECPGdebug causes crash on Windows XP