PL/PgSQL buglet / doc error - Mailing list pgsql-hackers

From Neil Conway
Subject PL/PgSQL buglet / doc error
Date
Msg-id 87smyd6j3t.fsf@mailbox.samurai.com
Whole thread Raw
Responses Re: PL/PgSQL buglet / doc error
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Larry Rosenman
Date:
Subject: Re: [PORTS] PostgreSQL supported platform report and a
Next
From: Stephan Szabo
Date:
Subject: Re: PL/PgSQL buglet / doc error