diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 17:50:24 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 17:50:24 -0500 |
commit | 47f3f97fcdee28e3eb70cd2ebfd7b4899570b018 (patch) | |
tree | 443f2edbb1c19fe1925f87f30e0edf66bc557b30 /src/backend/utils/adt/int.c | |
parent | 332741e73980401895e027eb697bb472860036fb (diff) | |
download | postgresql-47f3f97fcdee28e3eb70cd2ebfd7b4899570b018.tar.gz postgresql-47f3f97fcdee28e3eb70cd2ebfd7b4899570b018.zip |
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
Diffstat (limited to 'src/backend/utils/adt/int.c')
-rw-r--r-- | src/backend/utils/adt/int.c | 9 |
1 files changed, 5 insertions, 4 deletions
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"))); |