From 89def573ced57fc320ad191613dac62c8992c27a Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 12 Aug 2022 21:15:40 +0200 Subject: [PATCH v1 1/7] Fix reading of most-negative integer value nodes The main parser checks whether a literal fits into an int when deciding whether it should be put into an Integer or Float node. The parser processes integer literals without signs. So a most-negative integer literal will not fit into Integer and will end up as a Float node. The node tokenizer did this differently. It included the sign when checking whether the literal fit into int. So a most-negative integer would indeed fit that way and end up as an Integer node. In order to preserve the node structure correctly, we need the node tokenizer to also analyze integer literals without sign. There are a number of test cases in the regression tests that have a most-negative integer argument of some utility statement, so this issue is easily reproduced under WRITE_READ_PARSE_PLAN_TREES. --- src/backend/nodes/read.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index 4a54996b63..a9cb81b129 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -267,7 +267,7 @@ nodeTokenType(const char *token, int length) char *endptr; errno = 0; - (void) strtoint(token, &endptr, 10); + (void) strtoint(numptr, &endptr, 10); if (endptr != token + length || errno == ERANGE) return T_Float; return T_Integer; -- 2.37.1