Search Postgresql Archives

Re: function param and declared variable of same name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/01/2011 09:58 AM, Pavel Stehule wrote:
2011/9/1 Sim Zacks <sim@xxxxxxxxxxxxxx>:
Tested in 8.2 and 9.0.1

In plpgsql, if you have a function parameter and a variable of the same
name, it ignores the value passed in and initializes the variable to null.
The correct action, IMO, would be to raise an error.
You can access params via $n conventions. functions params and
functions variables are not in same space, so it should not be a
error. What behave is in PL/SQL? There should be problem with backward
compatibility when we change it.

Regards

Pavel Stehule
While you _can_ access the variable using the $n convention, it is an obvious mistake in the function definition. It may break existing functions, but all of those functions have bugs in them that will then be caught. Can you think of any valid case for passing in a variable and having the variable name refer to something else?

Sim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux