ERROR: control reached end of function without RETURN, except, it is not a function it is a procedure or a nameless block.

From: Herwig Goemans <herwig(dot)goemans(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: ERROR: control reached end of function without RETURN, except, it is not a function it is a procedure or a nameless block.
Date: 2021-09-13 11:23:06
Message-ID: 868ae948-e3ca-c7ec-95a6-83cfc08ef750@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Support,

I get an error in a stored procedure - not a stored function mind you -
control reached end of function without RETURN

The error occurs when doing an exit <label> in  a stored procedure. Now
I cannot give all of the stored procedures involved but I can simulate
te problem with a very simple block:

DO
$BODY$
<<simple_block>>
BEGIN
begin
               exit simple_block;
         -- for demo purposes
              raise notice '%', 'unreachable!';
   end;
   raise notice '%', 'End of block';
end;
$BODY$

This will return the error on Postgres version 13, Version 12 and 9.

Now I thought this was text-book behaviour of exiting a code block. I do
not like programming this way but it is part of a migration project of
Oracle to PG.

What do I miss ?

Kind regards,

If you put this code snippet in a file and execute like:

postgres(at)herwig-NUC10i7FNH:~$ psql -f  do_test.sql
psql:do_test.sql:12: ERROR:  control reached end of function without RETURN
CONTEXT:  PL/pgSQL function inline_code_block

Herwig

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2021-09-13 11:44:10 Re: ERROR: control reached end of function without RETURN, except, it is not a function it is a procedure or a nameless block.
Previous Message Kyotaro Horiguchi 2021-09-13 01:10:41 Re: Postgresql 11: terminating walsender process due to replication timeout