Skip to content

Commit 581a558

Browse files
committed
Fix nested error handling in PG_FINALLY
We need to pop the error stack before running the user-supplied PG_FINALLY code. Otherwise an error in the cleanup code would end up at the same sigsetjmp() invocation and result in an infinite error handling loop. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/95a822c3-728b-af0e-d7e5-71890507ae0c%402ndquadrant.com
1 parent a0c9685 commit 581a558

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/backend/utils/adt/xml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt)
38683868

38693869
result = xmlBuffer_to_xmltype(buf);
38703870
}
3871-
PG_FINALLY()
3871+
PG_FINALLY();
38723872
{
38733873
if (nodefree)
38743874
nodefree(cur_copy);

src/include/utils/elog.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,16 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
338338
} \
339339
else \
340340
_do_rethrow = true; \
341-
{
341+
{ \
342+
PG_exception_stack = _save_exception_stack; \
343+
error_context_stack = _save_context_stack
342344

343345
#define PG_END_TRY() \
344346
} \
345-
PG_exception_stack = _save_exception_stack; \
346-
error_context_stack = _save_context_stack; \
347347
if (_do_rethrow) \
348348
PG_RE_THROW(); \
349+
PG_exception_stack = _save_exception_stack; \
350+
error_context_stack = _save_context_stack; \
349351
} while (0)
350352

351353
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy