Re: Strange bahaviour

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange bahaviour
Дата
Msg-id 4036.1029159612@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strange bahaviour  (Michael Meskes <meskes@postgresql.org>)
Ответы Re: Strange bahaviour
Список pgsql-hackers
Michael Meskes <meskes@postgresql.org> writes:
> CREATE FUNCTION footest1(varchar(100)) RETURNS varchar(100) AS '
>         DECLARE
>                 login varchar(100);
>         BEGIN
>                 SELECT INTO login login FROM foo LIMIT 1;
>                 RETURN login;
>         END;
> ' LANGUAGE 'plpgsql';

> The first select returns NULL while the second correctly returns 'abc'.

The NULL is perfectly correct: that's the initial value of the plpgsql
variable.  The above is essentially the same as sayinglogin := login;
It is not "incorrect".

> Now I can guess what happens but I wonder if this is the desired
> behaviour.

Certainly, unless you'd like to disable all use of plpgsql variables in
SQL queries.  plpgsql has no way of guessing that "login" in the above
query wasn't intended to reference its variable.  Either choose a
different variable name, or qualify the query-variable reference
(eg, foo.login).
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Greg Copeland
Дата:
Сообщение: Re: [SECURITY] DoS attack on backend possible (was: Re:
Следующее
От: Florian Weimer
Дата:
Сообщение: Re: [SECURITY] DoS attack on backend possible (was: Re: