mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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
This commit is contained in:
@ -57,6 +57,7 @@ Datum
|
||||
tidin(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char *str = PG_GETARG_CSTRING(0);
|
||||
Node *escontext = fcinfo->context;
|
||||
char *p,
|
||||
*coord[NTIDARGS];
|
||||
int i;
|
||||
@ -71,7 +72,7 @@ tidin(PG_FUNCTION_ARGS)
|
||||
coord[i++] = p + 1;
|
||||
|
||||
if (i < NTIDARGS)
|
||||
ereport(ERROR,
|
||||
ereturn(escontext, (Datum) 0,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"tid", str)));
|
||||
@ -79,7 +80,7 @@ tidin(PG_FUNCTION_ARGS)
|
||||
errno = 0;
|
||||
cvt = strtoul(coord[0], &badp, 10);
|
||||
if (errno || *badp != DELIM)
|
||||
ereport(ERROR,
|
||||
ereturn(escontext, (Datum) 0,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"tid", str)));
|
||||
@ -93,7 +94,7 @@ tidin(PG_FUNCTION_ARGS)
|
||||
#if SIZEOF_LONG > 4
|
||||
if (cvt != (unsigned long) blockNumber &&
|
||||
cvt != (unsigned long) ((int32) blockNumber))
|
||||
ereport(ERROR,
|
||||
ereturn(escontext, (Datum) 0,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"tid", str)));
|
||||
@ -102,7 +103,7 @@ tidin(PG_FUNCTION_ARGS)
|
||||
cvt = strtoul(coord[1], &badp, 10);
|
||||
if (errno || *badp != RDELIM ||
|
||||
cvt > USHRT_MAX)
|
||||
ereport(ERROR,
|
||||
ereturn(escontext, (Datum) 0,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"tid", str)));
|
||||
|
Reference in New Issue
Block a user