The 7.3 docs for the PL/PgSQL return statement say:
RETURN with an expression is used to return from a PL/pgSQL functionthat does not return a set.
[...]
If you have declared the function to return void, then the expressioncan be omitted, and will be ignored in any case.
However, that does not seem to be the case:
nconway=# select version(); version
------------------------------------------------------------------PostgreSQL 7.4devel on i686-pc-linux-gnu, compiled by
GCC2.95.4
(1 row)
nconway=# create table bar (a int);
CREATE TABLE
nconway=# create or replace function test_func() returns void as
'begin insert into bar values (5); end;' language 'plpgsql';
CREATE FUNCTION
nconway=# select test_func();
WARNING: Error occurred while executing PL/pgSQL function test_func
WARNING: at END of toplevel PL block
ERROR: control reaches end of function without RETURN
nconway=# create or replace function test_func() returns void as
'begin insert into bar values (5); return; end;' language 'plpgsql';
CREATE FUNCTION
nconway=# select test_func();test_func
-----------
(1 row)
Should this be implemented, or should the assertion that 'RETURN is
optional' be removed from the docs?
Cheers,
Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC