diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 13:22:08 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-12-14 13:22:08 -0500 |
commit | 17407a8eaa2afa8ac0de4b0a494f33d8eb7a98bd (patch) | |
tree | 2fa2bc7dcfb3221e36390123978817174239fb71 /src/backend/utils/adt/mac.c | |
parent | b18c2decd76eeffbd483c041c02bb0fb01b0f124 (diff) | |
download | postgresql-17407a8eaa2afa8ac0de4b0a494f33d8eb7a98bd.tar.gz postgresql-17407a8eaa2afa8ac0de4b0a494f33d8eb7a98bd.zip |
Convert a few more datatype input functions to report errors softly.
Convert bit_in, varbit_in, inet_in, cidr_in, macaddr_in, and
macaddr8_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/mac.c')
-rw-r--r-- | src/backend/utils/adt/mac.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index ac7342cfca7..089450dac34 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -55,6 +55,7 @@ Datum macaddr_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + Node *escontext = fcinfo->context; macaddr *result; int a, b, @@ -88,7 +89,7 @@ macaddr_in(PG_FUNCTION_ARGS) count = sscanf(str, "%2x%2x%2x%2x%2x%2x%1s", &a, &b, &c, &d, &e, &f, junk); if (count != 6) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type %s: \"%s\"", "macaddr", str))); @@ -96,7 +97,7 @@ macaddr_in(PG_FUNCTION_ARGS) if ((a < 0) || (a > 255) || (b < 0) || (b > 255) || (c < 0) || (c > 255) || (d < 0) || (d > 255) || (e < 0) || (e > 255) || (f < 0) || (f > 255)) - ereport(ERROR, + ereturn(escontext, (Datum) 0, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("invalid octet value in \"macaddr\" value: \"%s\"", str))); |