git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a0c9685)
Fix nested error handling in PG_FINALLY
Thu, 7 Nov 2019 08:54:09 +0000 (09:54 +0100)
Thu, 7 Nov 2019 08:56:47 +0000 (09:56 +0100)
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


diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 3bc17164312c548b4723f210ddc979c2a507d7db..1ec16f49b296d9d058eafa7de071809d5c899a26 100644 (file)
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -3868,7 +3868,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt)
result = xmlBuffer_to_xmltype(buf);
}
- PG_FINALLY()
+ PG_FINALLY();
{
if (nodefree)
nodefree(cur_copy);
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 853c2e0709ed92f92c02937db118c9ff6be1ad14..47412a831f096acb84c84fb09ee577820d479766 100644 (file)
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -338,14 +338,16 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
} \
else \
_do_rethrow = true; \
- {
+ { \
+ PG_exception_stack = _save_exception_stack; \
+ error_context_stack = _save_context_stack
#define PG_END_TRY() \
} \
- PG_exception_stack = _save_exception_stack; \
- error_context_stack = _save_context_stack; \
if (_do_rethrow) \
PG_RE_THROW(); \
+ PG_exception_stack = _save_exception_stack; \
+ error_context_stack = _save_context_stack; \
} while (0)
/*
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /