Skip to content

Commit

Permalink
Remove InputFunctionCallSafe
Browse files Browse the repository at this point in the history
  • Loading branch information
robozmey committed Dec 12, 2024
1 parent 86d18ff commit 6ef970f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 65 deletions.
63 changes: 0 additions & 63 deletions src/backend/utils/fmgr/fmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,69 +1998,6 @@ InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
return result;
}

/*
* Call a previously-looked-up datatype input function, with non-exception
* handling of "soft" errors.
*
* This is basically like InputFunctionCall, but the converted Datum is
* returned into *result while the function result is true for success or
* false for failure. Also, the caller may pass an ErrorSaveContext node.
* (We declare that as "fmNodePtr" to avoid including nodes.h in fmgr.h.)
*
* If escontext points to an ErrorSaveContext, any "soft" errors detected by
* the input function will be reported by filling the escontext struct and
* returning (Datum) 0.
*
* If escontext does not point to an ErrorSaveContext, errors are reported
* via ereport(ERROR), so that there is no functional difference from
* InputFunctionCall; the result will always be true if control returns.
*/
Datum
InputFunctionCallSafe(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod, fmNodePtr escontext)
{
FunctionCallInfoData fcinfo;
Datum result;
bool pushed;

if (str == NULL && flinfo->fn_strict)
return (Datum) 0; /* just return null result */

pushed = SPI_push_conditional();

InitFunctionCallInfoData(fcinfo, flinfo, 3, InvalidOid, escontext, NULL);

fcinfo.arg[0] = CStringGetDatum(str);
fcinfo.arg[1] = ObjectIdGetDatum(typioparam);
fcinfo.arg[2] = Int32GetDatum(typmod);
fcinfo.argnull[0] = (str == NULL);
fcinfo.argnull[1] = false;
fcinfo.argnull[2] = false;

result = FunctionCallInvoke(&fcinfo);

/* Result value is garbage, and could be null, if an error was reported */
if (SOFT_ERROR_OCCURRED(escontext))
return (Datum) 0;

/* Should get null result if and only if str is NULL */
if (str == NULL)
{
if (!fcinfo.isnull)
elog(ERROR, "input function %u returned non-NULL",
fcinfo.flinfo->fn_oid);
}
else
{
if (fcinfo.isnull)
elog(ERROR, "input function %u returned NULL",
fcinfo.flinfo->fn_oid);
}

SPI_pop_conditional(pushed);

return result;
}

/*
* Call a previously-looked-up datatype output function.
*
Expand Down
2 changes: 0 additions & 2 deletions src/include/fmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,6 @@ extern Datum OidFunctionCall3CollSafe(Oid functionId, Oid collation,
/* Special cases for convenient invocation of datatype I/O functions. */
extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str,
Oid typioparam, int32 typmod);
extern Datum InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
Oid typioparam, int32 typmod, fmNodePtr escontext);
extern Datum OidInputFunctionCall(Oid functionId, char *str,
Oid typioparam, int32 typmod);
extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);
Expand Down

0 comments on commit 6ef970f

Please sign in to comment.