Hi, I created a tiny patch that documents that the code block following PG_TRY() cannot have any return statement.
Please CC me, as I'm not subscribed to this list.
commit 1968e53b9a649691fbedbdc059e2e933aa2b471b Author: Serpent7776 <serpent7...@gmail.com> Date: Tue Sep 12 14:38:09 2023 +0200 Document that PG_TRY block cannot have a return statement Document the fact that the block of code that follows `PG_TRY()` cannot have any form of return statement, because `PG_TRY()` modifies global state that is later restored in `PG_CATCH()` or `PG_FINALLY()`. diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 4a9562fdaa..f81b94b054 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -352,6 +352,8 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack; * You cannot use both PG_CATCH() and PG_FINALLY() in the same * PG_TRY()/PG_END_TRY() block. * + * There cannot be a return statement in the block of code following PG_TRY(). + * * Note: while the system will correctly propagate any new ereport(ERROR) * occurring in the recovery section, there is a small limit on the number * of levels this will work for. It's best to keep the error recovery