From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Karl O(dot) Pinc" <kop(at)meme(dot)com>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #1956: Plpgsql top-level DECLARE does not share scope |
Date: | 2005-10-13 17:30:56 |
Message-ID: | 23735.1129224656@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
"Jim C. Nasby" <jnasby(at)pervasive(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Walker | 2005-10-13 17:35:36 | BUG #1964: Role membership error |
Previous Message | Jim C. Nasby | 2005-10-13 17:11:10 | Re: BUG #1956: Plpgsql top-level DECLARE does not share scope |