public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
Subject: [PATCH v2 1/1] change SOFT_ERROR_OCCURRED to a static inline function
Date: Tue, 24 Mar 2026 15:51:58 -0500

---
 src/backend/executor/execExprInterp.c |  4 ++--
 src/backend/utils/adt/date.c          |  2 +-
 src/include/nodes/miscnodes.h         | 16 ++++++++++++----
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 43116431edf..bdb8037ba66 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -4961,7 +4961,7 @@ ExecEvalJsonExprPath(ExprState *state, ExprEvalStep *op,
 
 		fcinfo->isnull = false;
 		*op->resvalue = FunctionCallInvoke(fcinfo);
-		if (SOFT_ERROR_OCCURRED(&jsestate->escontext))
+		if (SOFT_ERROR_OCCURRED((Node *) &jsestate->escontext))
 			error = true;
 	}
 
@@ -5197,7 +5197,7 @@ ExecEvalJsonCoercionFinish(ExprState *state, ExprEvalStep *op)
 {
 	JsonExprState *jsestate = op->d.jsonexpr.jsestate;
 
-	if (SOFT_ERROR_OCCURRED(&jsestate->escontext))
+	if (SOFT_ERROR_OCCURRED((Node *) &jsestate->escontext))
 	{
 		/*
 		 * jsestate->error or jsestate->empty being set means that the error
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 71ea048d251..c3327440380 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -1402,7 +1402,7 @@ timestamptz_date(PG_FUNCTION_ARGS)
 	DateADT		result;
 
 	result = timestamptz2date_safe(timestamp, fcinfo->context);
-	if (SOFT_ERROR_OCCURRED(fcinfo->args))
+	if (SOFT_ERROR_OCCURRED(fcinfo->context))
 		PG_RETURN_NULL();
 
 	PG_RETURN_DATEADT(result);
diff --git a/src/include/nodes/miscnodes.h b/src/include/nodes/miscnodes.h
index ec833001ab0..72dc885069f 100644
--- a/src/include/nodes/miscnodes.h
+++ b/src/include/nodes/miscnodes.h
@@ -49,9 +49,17 @@ typedef struct ErrorSaveContext
 	ErrorData  *error_data;		/* details of error, if so */
 } ErrorSaveContext;
 
-/* Often-useful macro for checking if a soft error was reported */
-#define SOFT_ERROR_OCCURRED(escontext) \
-	((escontext) != NULL && IsA(escontext, ErrorSaveContext) && \
-	 ((ErrorSaveContext *) (escontext))->error_occurred)
+/* Often-useful function for checking if a soft error was reported */
+static inline bool
+SOFT_ERROR_OCCURRED(const Node *escontext)
+{
+	if (escontext == NULL)
+		return false;
+
+	if (!IsA(escontext, ErrorSaveContext))
+		return false;
+
+	return ((const ErrorSaveContext *) escontext)->error_occurred;
+}
 
 #endif							/* MISCNODES_H */
-- 
2.50.1 (Apple Git-155)


--X83H52P7q57jdRYd--





reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v2 1/1] change SOFT_ERROR_OCCURRED to a static inline function
  In-Reply-To: <no-message-id-724491@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox