From 4dd687502d9eb0b2984c36579c2fcf5283adfa7c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 9 Dec 2022 20:15:56 -0500 Subject: Restructure soft-error handling in formatting.c. Replace the error trapping scheme introduced in 5bc450629 with our shiny new errsave/ereturn mechanism. This doesn't have any real functional impact (although I think that the new coding is able to report a few more errors softly than v15 did). And I doubt there's any measurable performance difference either. But this gets rid of an ad-hoc, one-of-a-kind design in favor of a mechanism that will be widely used going forward, so it should be a net win for code readability. Discussion: https://postgr.es/m/3bbbb0df-7382-bf87-9737-340ba096e034@postgrespro.ru --- src/backend/utils/adt/jsonpath_exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/backend/utils/adt/jsonpath_exec.c') diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c index 930bd265842..e758616eb83 100644 --- a/src/backend/utils/adt/jsonpath_exec.c +++ b/src/backend/utils/adt/jsonpath_exec.c @@ -1808,7 +1808,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, text *template; char *template_str; int template_len; - bool have_error = false; + ErrorSaveContext escontext = {T_ErrorSaveContext}; jspGetArg(jsp, &elem); @@ -1822,9 +1822,9 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, value = parse_datetime(datetime, template, collid, true, &typid, &typmod, &tz, - jspThrowErrors(cxt) ? NULL : &have_error); + jspThrowErrors(cxt) ? NULL : (Node *) &escontext); - if (have_error) + if (escontext.error_occurred) res = jperError; else res = jperOk; @@ -1859,7 +1859,7 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, /* loop until datetime format fits */ for (i = 0; i < lengthof(fmt_str); i++) { - bool have_error = false; + ErrorSaveContext escontext = {T_ErrorSaveContext}; if (!fmt_txt[i]) { @@ -1872,9 +1872,9 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, value = parse_datetime(datetime, fmt_txt[i], collid, true, &typid, &typmod, &tz, - &have_error); + (Node *) &escontext); - if (!have_error) + if (!escontext.error_occurred) { res = jperOk; break; -- cgit v1.2.3