I trawled through git blame a bit and it looks like it's been that way for a very long time.
I think err_stmt should probably only be reset in the non-return case a bit below that. I'm not sure about err_text though. Also, the code treats PLPGSQL_RC_OK and PLPGSQL_RC_EXIT the same, which seems like a bug; I would think PLPGSQL_RC_EXIT should be handled the same way as CONTINUE.
If someone can confirm this and tell me what to do about err_text I'll submit a patch.
maybe "during function exit" ?
Regards
Pavel
[1] decibel@decina.attlocal/50703=# do $$ begin <<outer>> for a in 1..3 loop <<sub>> BEGIN <<inner>> for b in 8..9 loop if a=2 then continue sub; end if; raise notice '% %', a, b; end loop inner; END sub; end loop outer; end; $$; NOTICE: 1 8 NOTICE: 1 9 ERROR: CONTINUE cannot be used outside a loop CONTEXT: PL/pgSQL function inline_code_block decibel@decina.attlocal/50703=#