a few small bugs in plpgsql - Mailing list pgsql-hackers

From Pavel Stehule
Subject a few small bugs in plpgsql
Date
Msg-id AANLkTi=LgSXSej9qrRN+pobDovbiSF+7QcsUWWJBzwR=@mail.gmail.com
Whole thread Raw
Responses Re: a few small bugs in plpgsql  (Robert Haas <robertmhaas@gmail.com>)
Re: a few small bugs in plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello,

today I found a few bugs:

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
postgres=#

b) SRF functions must not be finished by RETURN statement - I know, so
there is outer default block, but it looks like inconsistency for SRF
functions, because you can use a RETURN NEXT without RETURN. It maybe
isn't bug - but I am filling it as inconsistency.

postgres=# CREATE OR REPLACE FUNCTION fg(OUT i int)
RETURNS SETOF int AS $$
BEGIN FOR i IN 1..3 LOOP fg.i := i;   RETURN NEXT; END LOOP;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION

postgres=# select fg();fg
---- 1 2 3
(3 rows)

Regards

Pavel Stehule


pgsql-hackers by date:

Previous
From: Markus Wanner
Date:
Subject: Re: Issues with Quorum Commit
Next
From: Robert Haas
Date:
Subject: Re: standby registration (was: is sync rep stalled?)