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