From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: a few small bugs in plpgsql |
Date: | 2010-10-08 04:08:52 |
Message-ID: | AANLkTi=HBjjMzn30EA+i-C2UMAN=ZH0xK8zGVp6PCWWE@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
2010/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)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.
>
I see it now - I did a bug <<<some>>, but with correct text there is same behave
CREATE OR REPLACE FUNCTION foo()
RETURNS void AS $$
BEGIN
FOR i IN 1..10
<<label>>
LOOP
RAISE NOTICE '%', i;
END LOOP;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION
Now I understand to interpretation. But there is little bit difficult
to understand to error message. Can be message enhanced to show a
complete expression? Some like
postgres=# select foo();
ERROR: column "label" does not exist
Detail: Expr 10 <<label>>
LINE 2: <<label>>
Regards
Pavel
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2010-10-08 04:13:38 | Re: a few small bugs in plpgsql |
Previous Message | Fujii Masao | 2010-10-08 03:41:29 | Re: Issues with Quorum Commit |