Re: Request for change in PL/PGSQL function handler - Mailing list pgsql-sql

From Tom Lane
Subject Re: Request for change in PL/PGSQL function handler
Date
Msg-id 3462.980535840@sss.pgh.pa.us
Whole thread Raw
In response to Request for change in PL/PGSQL function handler  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
Josh Berkus <josh@agliodbs.com> writes:
>     Currently (7.0.3) the PLPGSQL function compiler permits only one RETURN
> statment, at the end of the function.  RETURN statements placed
> elsewhere cause a compile error.

Say what?

regression=# create function foo(int) returns int as '
regression'# begin
regression'#   if $1 > 10 then return $1;
regression'#   end if;
regression'#   return $1 - 1;
regression'# end;' language 'plpgsql';
CREATE
regression=# select foo(1);foo
-----  0
(1 row)

regression=# select foo(100);foo
-----100
(1 row)

regression=#

Works fine for me in both 7.0.2 and current.
        regards, tom lane


pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Rule not invoked in 7.1
Next
From: Josh Berkus
Date:
Subject: Re: Request for change in PL/PGSQL function handler