The 7.3 docs for the PL/PgSQL return statement say:

 RETURN with an expression is used to return from a PL/pgSQL function
 that does not return a set.

[...]

 If you have declared the function to return void, then the expression
 can 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 GCC 2.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 <[EMAIL PROTECTED]> || PGP Key ID: DB3C29FC


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to