Fix for new Boolean node
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 17 Jan 2022 12:59:46 +0000 (13:59 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 17 Jan 2022 12:59:46 +0000 (13:59 +0100)
The token in nodeTokenType() is actually the whole rest of the string,
so we need to take into account the length to do the correct
comparison.

Without this, postgres_fdw tests fail under
-DWRITE_READ_PARSE_PLAN_TREES.

src/backend/nodes/read.c

index 8435203f2bd1dc811e224e8a6af51bfa38ef1899..1e61fde636777a0fb486ec2176a087fd2b77ab9b 100644 (file)
@@ -283,7 +283,8 @@ nodeTokenType(const char *token, int length)
        retval = RIGHT_PAREN;
    else if (*token == '{')
        retval = LEFT_BRACE;
-   else if (strcmp(token, "true") == 0 || strcmp(token, "false") == 0)
+   else if ((length == 4 && strncmp(token, "true", 4) == 0) ||
+            (length == 5 && strncmp(token, "false", 5) == 0))
        retval = T_Boolean;
    else if (*token == '"' && length > 1 && token[length - 1] == '"')
        retval = T_String;