Re: a few small bugs in plpgsql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: a few small bugs in plpgsql
Дата
Msg-id 11150.1286505430@sss.pgh.pa.us
обсуждение исходный текст
Ответ на a few small bugs in plpgsql  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: a few small bugs in plpgsql  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> a) parser allow a labels on invalid positions with strange runtime bug:

> postgres=# CREATE OR REPLACE FUNCTION foo()
> RETURNS void AS $$
> BEGIN
>   FOR i IN 1..2
>   <<<invalidLabel>>
>   LOOP
>     RAISE NOTICE '%',i;
>   END LOOP;
> END;
> $$ LANGUAGE plpgsql;
> CREATE FUNCTION

> ERROR:  column "invalidlabel" does not exist
> LINE 2:   <<<invalidLabel>>
>              ^
> QUERY:  SELECT 2
>   <<<invalidLabel>>
> CONTEXT:  PL/pgSQL function "foo" line 3 at FOR with integer loop variable

That isn't a bug, because the construct isn't a label, and wouldn't be
even if you'd gotten the number of <'s right ;-).  What you have is an
expression "2 <<< invalidLabel >>", which given the right operator
definitions could be perfectly valid.  plpgsql labels can't appear in
the middle of an SQL expression.
        regards, tom lane


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Issues with Quorum Commit
Следующее
От: Tom Lane
Дата:
Сообщение: Re: GIN vs. Partial Indexes