On 15.05.2017 18:31, Robert Haas wrote:
On Wed, May 10, 2017 at 12:11 PM, Konstantin Knizhnik
<k.knizh...@postgrespro.ru> wrote:
Robert, can you please explain why using TRY/CATCH is not safe here:
This is definitely not a safe way of using TRY/CATCH.
This has been discussed many, many times on this mailing list before,
and I don't really want to go over it again here.  We really need a
README or some documentation about this so that we don't have to keep
answering this same question again and again.

First of all I want to notice that new version of my patch is not using PG_TRY/PG_CATCH.
But I still want to clarify for myself whats wrong with this constructions.
I searched both hackers mailing list archive and world-wide using google but failed to find any references except of
sharing non-volatilie variables between try and catch blocks.
Can you please point me at the thread where this problem was discussed or just explain in few words the source of the problem?

From my own experience I found out that PG_TRY/PG_CATCH mechanism is not providing proper cleanup (unlike C++ exceptions). If there are opened relations, catalog cache entries,... then throwing error will not release them. It will cause no problems if error is handled in PostgresMain which aborts current transaction and releases all resources in any case. But if I want to ignore this error and continue query execution, then warnings about resources leaks can be reported.
Is it want you mean by unsafety of PG_TRY/PG_CATCH constructions?

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to