From b60af0fa8e1a8cb9139cdc884bc5e625a2bb1ee7 Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Sat, 27 Jun 2026 13:13:22 +0800
Subject: [PATCH v1 1/1] use InputFunctionCallSafe when possible

---
 src/backend/statistics/stat_utils.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/backend/statistics/stat_utils.c b/src/backend/statistics/stat_utils.c
index a673e3c704..05710e6b6b 100644
--- a/src/backend/statistics/stat_utils.c
+++ b/src/backend/statistics/stat_utils.c
@@ -569,7 +569,6 @@ Datum
 statatt_build_stavalues(const char *staname, FmgrInfo *array_in, Datum d, Oid typid,
 						int32 typmod, bool *ok)
 {
-	LOCAL_FCINFO(fcinfo, 8);
 	char	   *s;
 	Datum		result;
 	ErrorSaveContext escontext = {T_ErrorSaveContext};
@@ -578,21 +577,8 @@ statatt_build_stavalues(const char *staname, FmgrInfo *array_in, Datum d, Oid ty
 
 	s = TextDatumGetCString(d);
 
-	InitFunctionCallInfoData(*fcinfo, array_in, 3, InvalidOid,
-							 (Node *) &escontext, NULL);
-
-	fcinfo->args[0].value = CStringGetDatum(s);
-	fcinfo->args[0].isnull = false;
-	fcinfo->args[1].value = ObjectIdGetDatum(typid);
-	fcinfo->args[1].isnull = false;
-	fcinfo->args[2].value = Int32GetDatum(typmod);
-	fcinfo->args[2].isnull = false;
-
-	result = FunctionCallInvoke(fcinfo);
-
-	pfree(s);
-
-	if (escontext.error_occurred)
+	if (!InputFunctionCallSafe(array_in, s, typid, typmod,
+							   (Node *) &escontext, &result))
 	{
 		escontext.error_data->elevel = WARNING;
 		ThrowErrorData(escontext.error_data);
-- 
2.34.1

