Skip to content
Snippets Groups Projects
Commit 5e9e8849 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart
Browse files

Automatically promote out of range integers to floats.

Throw elog(NOTICE) to flag promotion.
parent 9e22f825
No related branches found
No related tags found
No related merge requests found
/* A lexical scanner generated by flex */ /* A lexical scanner generated by flex */
/* Scanner skeleton version: /* Scanner skeleton version:
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.11 1998/02/02 00:03:39 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.12 1998/02/11 03:56:08 thomas Exp $
*/ */
#define FLEX_SCANNER #define FLEX_SCANNER
...@@ -539,7 +539,7 @@ char *yytext; ...@@ -539,7 +539,7 @@ char *yytext;
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.11 1998/02/02 00:03:39 scrappy Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.12 1998/02/11 03:56:08 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1158,14 +1158,22 @@ YY_RULE_SETUP ...@@ -1158,14 +1158,22 @@ YY_RULE_SETUP
BEGIN(xm); BEGIN(xm);
errno = 0; errno = 0;
yylval.ival = strtol((char *)yytext,&endptr,10); yylval.ival = strtol((char *)yytext,&endptr,10);
if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(ERROR,"Bad integer input '%s'",yytext); 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);
}
return (ICONST); return (ICONST);
} }
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 324 "scan.l" #line 332 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1180,20 +1188,28 @@ YY_RULE_SETUP ...@@ -1180,20 +1188,28 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 335 "scan.l" #line 343 "scan.l"
{ {
char* endptr; char* endptr;
errno = 0; errno = 0;
yylval.ival = strtol((char *)yytext,&endptr,10); yylval.ival = strtol((char *)yytext,&endptr,10);
if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(ERROR,"Bad integer input '%s'",yytext); 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);
}
return (ICONST); return (ICONST);
} }
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 344 "scan.l" #line 360 "scan.l"
{ {
char* endptr; char* endptr;
...@@ -1207,7 +1223,7 @@ YY_RULE_SETUP ...@@ -1207,7 +1223,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 354 "scan.l" #line 370 "scan.l"
{ {
int i; int i;
ScanKeyword *keyword; ScanKeyword *keyword;
...@@ -1229,20 +1245,20 @@ YY_RULE_SETUP ...@@ -1229,20 +1245,20 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 372 "scan.l" #line 388 "scan.l"
{ /* ignore */ } { /* ignore */ }
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 374 "scan.l" #line 390 "scan.l"
{ return (yytext[0]); } { return (yytext[0]); }
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 376 "scan.l" #line 392 "scan.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1246 "lex.yy.c" #line 1262 "lex.yy.c"
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(xb): case YY_STATE_EOF(xb):
case YY_STATE_EOF(xc): case YY_STATE_EOF(xc):
...@@ -2128,7 +2144,7 @@ int main() ...@@ -2128,7 +2144,7 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 376 "scan.l" #line 392 "scan.l"
void yyerror(char message[]) void yyerror(char message[])
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.34 1998/01/05 16:39:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.35 1998/02/11 03:56:07 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -317,8 +317,16 @@ other . ...@@ -317,8 +317,16 @@ other .
BEGIN(xm); BEGIN(xm);
errno = 0; errno = 0;
yylval.ival = strtol((char *)yytext,&endptr,10); yylval.ival = strtol((char *)yytext,&endptr,10);
if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(ERROR,"Bad integer input '%s'",yytext); 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);
}
return (ICONST); return (ICONST);
} }
{real}/{space}*-{number} { {real}/{space}*-{number} {
...@@ -337,8 +345,16 @@ other . ...@@ -337,8 +345,16 @@ other .
errno = 0; errno = 0;
yylval.ival = strtol((char *)yytext,&endptr,10); yylval.ival = strtol((char *)yytext,&endptr,10);
if (*endptr != '\0' || errno == ERANGE)
{
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
elog(ERROR,"Bad integer input '%s'",yytext); 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);
}
return (ICONST); return (ICONST);
} }
{real} { {real} {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment