Re: function param and declared variable of same name
От | Sim Zacks |
---|---|
Тема | Re: function param and declared variable of same name |
Дата | |
Msg-id | 4E5F3810.7000505@compulab.co.il обсуждение исходный текст |
Ответ на | function param and declared variable of same name (Sim Zacks <sim@compulab.co.il>) |
Список | pgsql-general |
On 09/01/2011 09:58 AM, Pavel Stehule wrote: <blockquote cite="mid:CAFj8pRBtVU4Ry5VJL6CRBzEOqbOA7se38aLORY6ooPAnNa0eUg@mail.gmail.com"type="cite"><pre wrap="">2011/9/1 Sim Zacks<a class="moz-txt-link-rfc2396E" href="mailto:sim@compulab.co.il"><sim@compulab.co.il></a>: </pre><blockquote type="cite"><pre wrap="">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. </pre></blockquote><pre wrap=""> 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</pre></blockquote> While you _can_ access the variable using the $n convention, it is an obvious mistake inthe function definition. It may break existing functions, but all of those functions have bugs in them that will then becaught. Can you think of any valid case for passing in a variable and having the variable name refer to something else?<br /><br /> Sim<br />
В списке pgsql-general по дате отправления: