From 47f3f97fcdee28e3eb70cd2ebfd7b4899570b018 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 14 Dec 2022 17:50:24 -0500 Subject: Convert a few more datatype input functions to report errors softly. Convert assorted internal-ish datatypes, namely aclitemin, int2vectorin, oidin, oidvectorin, pg_lsn_in, pg_snapshot_in, and tidin to the new style. (Some others you might expect to find in this group, such as cidin and xidin, need no changes because they never throw errors at all. That seems a little cheesy ... but it is not in the charter of this patch series to add new error conditions.) Amul Sul, minor mods by me Discussion: https://postgr.es/m/CAAJ_b97KeDWUdpTKGOaFYPv0OicjOu6EW+QYWj-Ywrgj_aEy1g@mail.gmail.com --- src/backend/utils/adt/int.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/backend/utils/adt/int.c') diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 8de38abd11d..2c90e526a60 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -141,6 +141,7 @@ Datum int2vectorin(PG_FUNCTION_ARGS) { char *intString = PG_GETARG_CSTRING(0); + Node *escontext = fcinfo->context; int2vector *result; int n; @@ -160,19 +161,19 @@ int2vectorin(PG_FUNCTION_ARGS) l = strtol(intString, &endp, 10); if (intString == endp) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type %s: \"%s\"", "smallint", intString))); if (errno == ERANGE || l < SHRT_MIN || l > SHRT_MAX) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("value \"%s\" is out of range for type %s", intString, "smallint"))); if (*endp && *endp != ' ') - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type %s: \"%s\"", "integer", intString))); @@ -183,7 +184,7 @@ int2vectorin(PG_FUNCTION_ARGS) while (*intString && isspace((unsigned char) *intString)) intString++; if (*intString) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("int2vector has too many elements"))); -- cgit v1.2.3