}
/*
- * 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.
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 = {
};
*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
* 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;
}
/*
- * 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
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};
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,