diff --git a/src/backend/statistics/extended_stats_funcs.c b/src/backend/statistics/extended_stats_funcs.c index 2cb3942056f..a5dce8a2206 100644 --- a/src/backend/statistics/extended_stats_funcs.c +++ b/src/backend/statistics/extended_stats_funcs.c @@ -1033,7 +1033,7 @@ jbv_to_infunc_datum(JsonbValue *jval, PGFunction func, AttrNumber exprnum, } /* - * Build an array datum with element type elemtypid from a text datum, used as + * Build an array datum with element type typid from a text datum, used as * value of an attribute in a pg_statistic tuple. * * If an error is encountered, capture it, and reduce the elevel to WARNING. @@ -1044,7 +1044,6 @@ static Datum array_in_safe(FmgrInfo *array_in, const char *s, Oid typid, int32 typmod, AttrNumber exprnum, const char *element_name, bool *ok) { - LOCAL_FCINFO(fcinfo, 3); Datum result; ErrorSaveContext escontext = { @@ -1053,17 +1052,6 @@ array_in_safe(FmgrInfo *array_in, const char *s, Oid typid, int32 typmod, }; *ok = false; - 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); /* * If the array_in function returned an error, we will want to report that @@ -1071,7 +1059,8 @@ array_in_safe(FmgrInfo *array_in, const char *s, Oid typid, int32 typmod, * Overwriting the existing hint (if any) is not ideal, and an error * context would only work for level >= ERROR. */ - if (escontext.error_occurred) + if (!InputFunctionCallSafe(array_in, (char *) s, typid, typmod, + (Node *) &escontext, &result)) { StringInfoData hint_str; diff --git a/src/backend/statistics/stat_utils.c b/src/backend/statistics/stat_utils.c index a673e3c704b..0b190e88237 100644 --- a/src/backend/statistics/stat_utils.c +++ b/src/backend/statistics/stat_utils.c @@ -555,7 +555,7 @@ statatt_get_elem_type(Oid atttypid, char atttyptype, } /* - * Build an array with element type elemtypid from a text datum, used as + * Build an array with element type typid from a text datum, used as * value of an attribute in a tuple to-be-inserted into pg_statistic. * * The typid and typmod should be derived from a previous call to @@ -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,28 +577,18 @@ 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)) { + pfree(s); escontext.error_data->elevel = WARNING; ThrowErrorData(escontext.error_data); *ok = false; return (Datum) 0; } + pfree(s); + if (ARR_NDIM(DatumGetArrayTypeP(result)) != 1) { ereport(WARNING,