"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