wrong plpgsql's line counting 9.1

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: wrong plpgsql's line counting 9.1
Date: 2011-08-19 10:21:53
Message-ID: CAFj8pRAFKmqvwFi2isMaAEbNJR4YSGVUuCUK00QO=1RBO4=uww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2011-08-19 10:31:10 Re: wrong plpgsql's line counting 9.1
Previous Message Kohei KaiGai 2011-08-19 10:05:58 Re: [v9.1] sepgsql - userspace access vector cache