mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Change internal integer representation of Value node
A Value node would store an integer as a long. This causes needless portability risks, as long can be of varying sizes. Change it to use int instead. All code using this was already careful to only store 32-bit values anyway. Reviewed-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
@@ -3235,7 +3235,7 @@ _outValue(StringInfo str, const Value *value)
|
||||
switch (value->type)
|
||||
{
|
||||
case T_Integer:
|
||||
appendStringInfo(str, "%ld", value->val.ival);
|
||||
appendStringInfo(str, "%d", value->val.ival);
|
||||
break;
|
||||
case T_Float:
|
||||
|
||||
|
||||
@@ -224,13 +224,9 @@ nodeTokenType(char *token, int length)
|
||||
|
||||
errno = 0;
|
||||
val = strtol(token, &endptr, 10);
|
||||
(void) val; /* avoid compiler warning if unused */
|
||||
if (endptr != token + length || errno == ERANGE
|
||||
#ifdef HAVE_LONG_INT_64
|
||||
/* if long > 32 bits, check for overflow of int4 */
|
||||
|| val != (long) ((int32) val)
|
||||
#endif
|
||||
)
|
||||
if (endptr != token + length || errno == ERANGE ||
|
||||
/* check for overflow of int */
|
||||
val != (int) val)
|
||||
return T_Float;
|
||||
return T_Integer;
|
||||
}
|
||||
@@ -387,9 +383,9 @@ nodeRead(char *token, int tok_len)
|
||||
case T_Integer:
|
||||
|
||||
/*
|
||||
* we know that the token terminates on a char atol will stop at
|
||||
* we know that the token terminates on a char atoi will stop at
|
||||
*/
|
||||
result = (Node *) makeInteger(atol(token));
|
||||
result = (Node *) makeInteger(atoi(token));
|
||||
break;
|
||||
case T_Float:
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* makeInteger
|
||||
*/
|
||||
Value *
|
||||
makeInteger(long i)
|
||||
makeInteger(int i)
|
||||
{
|
||||
Value *v = makeNode(Value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user