diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 18:03:11 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 18:03:11 -0500 |
commit | 90161dad4dd719f44255474f4471af916f2a28f0 (patch) | |
tree | 3133eabda50dd4b11f4d02aecefe875b7961547d /src/backend/utils/adt/cash.c | |
parent | 47f3f97fcdee28e3eb70cd2ebfd7b4899570b018 (diff) | |
download | postgresql-90161dad4dd719f44255474f4471af916f2a28f0.tar.gz postgresql-90161dad4dd719f44255474f4471af916f2a28f0.zip |
Convert a few more datatype input functions to report errors softly.
Convert cash_in and uuid_in to the new style.
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/cash.c')
-rw-r--r-- | src/backend/utils/adt/cash.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index f7e78fa1056..32fbad2f57d 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -96,6 +96,7 @@ Datum cash_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + Node *escontext = fcinfo->context; Cash result; Cash value = 0; Cash dec = 0; @@ -209,7 +210,7 @@ cash_in(PG_FUNCTION_ARGS) if (pg_mul_s64_overflow(value, 10, &value) || pg_sub_s64_overflow(value, digit, &value)) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("value \"%s\" is out of range for type %s", str, "money"))); @@ -234,7 +235,7 @@ cash_in(PG_FUNCTION_ARGS) { /* remember we build the value in the negative */ if (pg_sub_s64_overflow(value, 1, &value)) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("value \"%s\" is out of range for type %s", str, "money"))); @@ -244,7 +245,7 @@ cash_in(PG_FUNCTION_ARGS) for (; dec < fpoint; dec++) { if (pg_mul_s64_overflow(value, 10, &value)) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("value \"%s\" is out of range for type %s", str, "money"))); @@ -271,7 +272,7 @@ cash_in(PG_FUNCTION_ARGS) else if (strncmp(s, csymbol, strlen(csymbol)) == 0) s += strlen(csymbol); else - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type %s: \"%s\"", "money", str))); @@ -284,7 +285,7 @@ cash_in(PG_FUNCTION_ARGS) if (sgn > 0) { if (value == PG_INT64_MIN) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("value \"%s\" is out of range for type %s", str, "money"))); |