mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Change parse-time representation of float literals (which include oversize
integers) to be strings instead of 'double'. We convert from string form to internal representation only after type resolution has determined the correct type for the constant. This eliminates loss-of-precision worries and gets rid of the change in behavior seen at 17 digits with the previous kluge.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.64 2000/02/19 04:17:25 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.65 2000/02/21 18:47:02 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -324,7 +324,7 @@ other .
|
||||
}
|
||||
|
||||
{param} {
|
||||
yylval.ival = atoi((char*)&yytext[1]);
|
||||
yylval.ival = atol((char*)&yytext[1]);
|
||||
return PARAM;
|
||||
}
|
||||
|
||||
@@ -332,46 +332,21 @@ other .
|
||||
char* endptr;
|
||||
|
||||
errno = 0;
|
||||
yylval.ival = strtol((char *)yytext,&endptr,10);
|
||||
yylval.ival = strtol((char *)yytext, &endptr, 10);
|
||||
if (*endptr != '\0' || errno == ERANGE)
|
||||
{
|
||||
errno = 0;
|
||||
#if 0
|
||||
yylval.dval = strtod(((char *)yytext),&endptr);
|
||||
if (*endptr != '\0' || errno == ERANGE)
|
||||
elog(ERROR,"Bad integer input '%s'",yytext);
|
||||
CheckFloat8Val(yylval.dval);
|
||||
elog(NOTICE,"Integer input '%s' is out of range; promoted to float", yytext);
|
||||
return FCONST;
|
||||
#endif
|
||||
/* integer too large, treat it as a float */
|
||||
yylval.str = pstrdup((char*)yytext);
|
||||
return SCONST;
|
||||
return FCONST;
|
||||
}
|
||||
return ICONST;
|
||||
}
|
||||
{decimal} {
|
||||
char* endptr;
|
||||
|
||||
if (strlen((char *)yytext) <= 17)
|
||||
{
|
||||
errno = 0;
|
||||
yylval.dval = strtod((char *)yytext,&endptr);
|
||||
if (*endptr != '\0' || errno == ERANGE)
|
||||
elog(ERROR,"Bad float input '%s'",yytext);
|
||||
CheckFloat8Val(yylval.dval);
|
||||
return FCONST;
|
||||
}
|
||||
yylval.str = pstrdup((char*)yytext);
|
||||
return SCONST;
|
||||
return FCONST;
|
||||
}
|
||||
{real} {
|
||||
char* endptr;
|
||||
|
||||
errno = 0;
|
||||
yylval.dval = strtod((char *)yytext,&endptr);
|
||||
if (*endptr != '\0' || errno == ERANGE)
|
||||
elog(ERROR,"Bad float input '%s'",yytext);
|
||||
CheckFloat8Val(yylval.dval);
|
||||
yylval.str = pstrdup((char*)yytext);
|
||||
return FCONST;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user