diff options
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/scan.l | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l index f913584c1a7..0f876e7718c 100644 --- a/src/backend/parser/scan.l +++ b/src/backend/parser/scan.l @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.87 2001/02/21 18:53:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.88 2001/03/22 17:41:47 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -310,14 +310,21 @@ other . startlit(); } <xh>{xhstop} { + long val; char* endptr; BEGIN(INITIAL); errno = 0; - yylval.ival = strtol(literalbuf, &endptr, 16); - if (*endptr != '\0' || errno == ERANGE) + val = strtol(literalbuf, &endptr, 16); + if (*endptr != '\0' || errno == ERANGE +#ifdef HAVE_LONG_INT_64 + /* if long > 32 bits, check for overflow of int4 */ + || val != (long) ((int32) val) +#endif + ) elog(ERROR, "Bad hexadecimal integer input '%s'", literalbuf); + yylval.ival = val; return ICONST; } <xh><<EOF>> { elog(ERROR, "Unterminated hexadecimal integer"); } @@ -454,16 +461,23 @@ other . } {integer} { + long val; char* endptr; errno = 0; - yylval.ival = strtol((char *)yytext, &endptr, 10); - if (*endptr != '\0' || errno == ERANGE) + val = strtol((char *)yytext, &endptr, 10); + if (*endptr != '\0' || errno == ERANGE +#ifdef HAVE_LONG_INT_64 + /* if long > 32 bits, check for overflow of int4 */ + || val != (long) ((int32) val) +#endif + ) { /* integer too large, treat it as a float */ yylval.str = pstrdup((char*)yytext); return FCONST; } + yylval.ival = val; return ICONST; } {decimal} { |