Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+1-1
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

+5-3
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)