Hello

I found a bug in plpgsql parser.


create table t(a int, b int);

postgres=# \sf fx
CREATE OR REPLACE FUNCTION public.fx()
RETURNS void
LANGUAGE plpgsql
AS $function$
declare r record;
begin
r := (10,20)::t;
if true then
raise notice '% %', r.c, r.b;
end if;
end;
$function$

postgres=# select fx();
ERROR: record "r" has no field "c"
CONTEXT: SQL statement "SELECT r.c"
PL/pgSQL function "fx" line 4 during function entry

it reports a bug on line 4, but it should to be 6

postgres=# \sf+ fx
CREATE OR REPLACE FUNCTION public.fx()
RETURNS void
LANGUAGE plpgsql
1 AS $function$
2 declare r record;
3 begin
4 r := (10,20)::t;
5 if true then
6 raise notice '% %', r.c, r.b;
7 end if;
8 end;
9 $function$

Regards

Pavel Stehule

Search Discussions

  • Pavel Stehule at Aug 19, 2011 at 10:31 am
    Hello

    I am sorry, it's noise

    regards

    Pavel

    2011/8/19 Pavel Stehule <pavel.stehule@gmail.com>:
    Hello

    I found a bug in plpgsql parser.


    create table t(a int, b int);

    postgres=# \sf fx
    CREATE OR REPLACE FUNCTION public.fx()
    RETURNS void
    LANGUAGE plpgsql
    AS $function$
    declare r record;
    begin
    r := (10,20)::t;
    if true then
    raise notice '% %', r.c, r.b;
    end if;
    end;
    $function$

    postgres=# select fx();
    ERROR:  record "r" has no field "c"
    CONTEXT:  SQL statement "SELECT r.c"
    PL/pgSQL function "fx" line 4 during function entry

    it reports a bug on line 4, but it should to be 6

    postgres=# \sf+ fx
    CREATE OR REPLACE FUNCTION public.fx()
    RETURNS void
    LANGUAGE plpgsql
    1       AS $function$
    2       declare r record;
    3       begin
    4         r := (10,20)::t;
    5         if true then
    6           raise notice '% %', r.c, r.b;
    7         end if;
    8       end;
    9       $function$

    Regards

    Pavel Stehule

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedAug 19, '11 at 10:22a
activeAug 19, '11 at 10:31a
posts2
users1
websitepostgresql.org...
irc#postgresql

1 user in discussion

Pavel Stehule: 2 posts

People

Translate

site design / logo © 2021 Grokbase