Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-17 Thread Pavel Stehule
Hello there is VIP patch of plpgsql_check_function that supports this warning Regards Pavel 2012/4/15 Pavel Stehule : > 2012/4/15 Tom Lane : >> Pavel Stehule writes: >>> We can raise warning from CREATE OR REPLACE FUNCTION - but I would to >>> like have plpgsql_check_function inside core - an

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Pavel Stehule
2012/4/15 Tom Lane : > Pavel Stehule writes: >> We can raise warning from CREATE OR REPLACE FUNCTION - but I would to >> like have plpgsql_check_function inside core - and it is better place >> for this and similar issues. > > I agree.  This is a perfectly legal use of nested declaration scopes, >

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Tom Lane
Pavel Stehule writes: > We can raise warning from CREATE OR REPLACE FUNCTION - but I would to > like have plpgsql_check_function inside core - and it is better place > for this and similar issues. I agree. This is a perfectly legal use of nested declaration scopes, so it would be totally inappro

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Andrew Dunstan
On 04/15/2012 03:49 AM, Brendan Jurd wrote: Hello hackers, It turns out that in a PL/PgSQL function, you can DECLARE a variable using the same name as one of the function parameters. This has the effect of clobbering the parameter, for example: ... I would suggest that if the user DECLARE

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Pavel Stehule
2012/4/15 Brendan Jurd : > On 15 April 2012 18:54, Pavel Stehule wrote: >> 2012/4/15 Brendan Jurd : >>> Perhaps it's a failure of imagination on my part, but I can't think of >>> a legitimate reason for a programmer to deliberately use the same name >>> to refer to a declared variable and a functi

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Brendan Jurd
On 15 April 2012 18:54, Pavel Stehule wrote: > 2012/4/15 Brendan Jurd : >> Perhaps it's a failure of imagination on my part, but I can't think of >> a legitimate reason for a programmer to deliberately use the same name >> to refer to a declared variable and a function parameter.  What would >> be

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Pavel Stehule
2012/4/15 Brendan Jurd : > On 15 April 2012 17:55, Pavel Stehule wrote: >> 2012/4/15 Brendan Jurd : >>> It turns out that in a PL/PgSQL function, you can DECLARE a variable >>> using the same name as one of the function parameters.  This has the >>> effect of clobbering the parameter, for example:

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Brendan Jurd
On 15 April 2012 17:55, Pavel Stehule wrote: > 2012/4/15 Brendan Jurd : >> It turns out that in a PL/PgSQL function, you can DECLARE a variable >> using the same name as one of the function parameters.  This has the >> effect of clobbering the parameter, for example: >> ... >> >> I would suggest t

Re: [HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Pavel Stehule
2012/4/15 Brendan Jurd : > Hello hackers, > > It turns out that in a PL/PgSQL function, you can DECLARE a variable > using the same name as one of the function parameters.  This has the > effect of clobbering the parameter, for example: > > CREATE OR REPLACE FUNCTION declare_clobber(foo int) > RETU

[HACKERS] Clobbered parameter names via DECLARE in PL/PgSQL

2012-04-15 Thread Brendan Jurd
Hello hackers, It turns out that in a PL/PgSQL function, you can DECLARE a variable using the same name as one of the function parameters. This has the effect of clobbering the parameter, for example: CREATE OR REPLACE FUNCTION declare_clobber(foo int) RETURNS int LANGUAGE plpgsql AS $$