mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Remove pg_atoi()
The last caller was int2vectorin(), and having such a general function for one user didn't seem useful, so just put the required parts inline and remove the function. Reviewed-by: John Naylor <john.naylor@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/b239564c-cad0-b23e-c57e-166d883cb97d@enterprisedb.com
This commit is contained in:
@@ -146,15 +146,39 @@ int2vectorin(PG_FUNCTION_ARGS)
|
||||
|
||||
result = (int2vector *) palloc0(Int2VectorSize(FUNC_MAX_ARGS));
|
||||
|
||||
for (n = 0; *intString && n < FUNC_MAX_ARGS; n++)
|
||||
for (n = 0; n < FUNC_MAX_ARGS; n++)
|
||||
{
|
||||
long l;
|
||||
char *endp;
|
||||
|
||||
while (*intString && isspace((unsigned char) *intString))
|
||||
intString++;
|
||||
if (*intString == '\0')
|
||||
break;
|
||||
result->values[n] = pg_atoi(intString, sizeof(int16), ' ');
|
||||
while (*intString && !isspace((unsigned char) *intString))
|
||||
intString++;
|
||||
|
||||
errno = 0;
|
||||
l = strtol(intString, &endp, 10);
|
||||
|
||||
if (intString == endp)
|
||||
ereport(ERROR,
|
||||
(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,
|
||||
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
|
||||
errmsg("value \"%s\" is out of range for type %s", intString,
|
||||
"smallint")));
|
||||
|
||||
if (*endp && *endp != ' ')
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
|
||||
errmsg("invalid input syntax for type %s: \"%s\"",
|
||||
"integer", intString)));
|
||||
|
||||
result->values[n] = l;
|
||||
intString = endp;
|
||||
}
|
||||
while (*intString && isspace((unsigned char) *intString))
|
||||
intString++;
|
||||
|
||||
Reference in New Issue
Block a user