]> granicus.if.org Git - postgresql/blobdiff - src/backend/nodes/read.c
Change internal integer representation of Value node
[postgresql] / src / backend / nodes / read.c
index 2f0210b8daf2bc829a76945d868c30a461183faa..6e9fa45e37e37ff91c000e48d844d629b2b69f18 100644 (file)
@@ -4,7 +4,7 @@
  *       routines to convert a string (legal ascii representation of node) back
  *       to nodes
  *
- * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
@@ -85,21 +85,21 @@ stringToNode(char *str)
  *       Backslashes themselves must also be backslashed for consistency.
  *       Any other character can be, but need not be, backslashed as well.
  *     * If the resulting token is '<>' (with no backslash), it is returned
- *       as a non-NULL pointer to the token but with length == 0.      Note that
+ *       as a non-NULL pointer to the token but with length == 0.  Note that
  *       there is no other way to get a zero-length token.
  *
  * Returns a pointer to the start of the next token, and the length of the
- * token (including any embedded backslashes!) in *length.     If there are
+ * token (including any embedded backslashes!) in *length.  If there are
  * no more tokens, NULL and 0 are returned.
  *
  * NOTE: this routine doesn't remove backslashes; the caller must do so
  * if necessary (see "debackslash").
  *
  * NOTE: prior to release 7.0, this routine also had a special case to treat
- * a token starting with '"' as extending to the next '"'.     This code was
+ * a token starting with '"' as extending to the next '"'.  This code was
  * broken, however, since it would fail to cope with a string containing an
  * embedded '"'.  I have therefore removed this special case, and instead
- * introduced rules for using backslashes to quote characters. Higher-level
+ * introduced rules for using backslashes to quote characters.  Higher-level
  * code should add backslashes to a string constant to ensure it is treated
  * as a single token.
  */
@@ -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;
        }
@@ -245,7 +241,7 @@ nodeTokenType(char *token, int length)
                retval = RIGHT_PAREN;
        else if (*token == '{')
                retval = LEFT_BRACE;
-       else if (*token == '\"' && length > 1 && token[length - 1] == '\"')
+       else if (*token == '"' && length > 1 && token[length - 1] == '"')
                retval = T_String;
        else if (*token == 'b')
                retval = T_BitString;
@@ -259,7 +255,7 @@ nodeTokenType(char *token, int length)
  *       Slightly higher-level reader.
  *
  * This routine applies some semantic knowledge on top of the purely
- * lexical tokenizer pg_strtok().      It can read
+ * lexical tokenizer pg_strtok().   It can read
  *     * Value token nodes (integers, floats, or strings);
  *     * General nodes (via parseNodeString() from readfuncs.c);
  *     * Lists of the above;
@@ -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:
                        {