Automatically promote out of range integers to floats.
authorThomas G. Lockhart <lockhart@fourpalms.org>
Wed, 11 Feb 1998 03:56:08 +0000 (03:56 +0000)
committerThomas G. Lockhart <lockhart@fourpalms.org>
Wed, 11 Feb 1998 03:56:08 +0000 (03:56 +0000)
Throw elog(NOTICE) to flag promotion.

src/backend/parser/scan.c
src/backend/parser/scan.l

index 8785f35d83cf85088f60d3aa7e4014649c1caba7..74f72609fcb8a3e842bd2dc8f9ad97f5c34aa0df 100644 (file)
@@ -1,7 +1,7 @@
 /* A lexical scanner generated by flex */
 
 /* 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
@@ -539,7 +539,7 @@ char *yytext;
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -1159,13 +1159,21 @@ YY_RULE_SETUP
                    errno = 0;
                    yylval.ival = strtol((char *)yytext,&endptr,10);
                    if (*endptr != '\0' || errno == ERANGE)
-                       elog(ERROR,"Bad integer input '%s'",yytext);
+                   {
+                       errno = 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);
+                   }
                    return (ICONST);
                }
    YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 324 "scan.l"
+#line 332 "scan.l"
 {
                    char* endptr;
 
@@ -1173,27 +1181,35 @@ YY_RULE_SETUP
                    errno = 0;
                    yylval.dval = strtod(((char *)yytext),&endptr);
                    if (*endptr != '\0' || errno == ERANGE)
-                   elog(ERROR,"Bad float8 input '%s'",yytext);
+                       elog(ERROR,"Bad float8 input '%s'",yytext);
                    CheckFloat8Val(yylval.dval);
                    return (FCONST);
                }
    YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 335 "scan.l"
+#line 343 "scan.l"
 {
                    char* endptr;
 
                    errno = 0;
                    yylval.ival = strtol((char *)yytext,&endptr,10);
                    if (*endptr != '\0' || errno == ERANGE)
-                       elog(ERROR,"Bad integer input '%s'",yytext);
+                   {
+                       errno = 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);
+                   }
                    return (ICONST);
                }
    YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 344 "scan.l"
+#line 360 "scan.l"
 {
                    char* endptr;
 
@@ -1207,7 +1223,7 @@ YY_RULE_SETUP
    YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 354 "scan.l"
+#line 370 "scan.l"
 {
                    int i;
                    ScanKeyword     *keyword;
@@ -1229,20 +1245,20 @@ YY_RULE_SETUP
    YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 372 "scan.l"
+#line 388 "scan.l"
 { /* ignore */ }
    YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 374 "scan.l"
+#line 390 "scan.l"
 { return (yytext[0]); }
    YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 376 "scan.l"
+#line 392 "scan.l"
 ECHO;
    YY_BREAK
-#line 1246 "lex.yy.c"
+#line 1262 "lex.yy.c"
            case YY_STATE_EOF(INITIAL):
            case YY_STATE_EOF(xb):
            case YY_STATE_EOF(xc):
@@ -2128,7 +2144,7 @@ int main()
    return 0;
    }
 #endif
-#line 376 "scan.l"
+#line 392 "scan.l"
 
 
 void yyerror(char message[])
index 95a5cc31f2c4a9dee2d0da111696e48bac219e5c..09034b6ab69d6051452e1ffd7cde90d1b759abea 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -318,7 +318,15 @@ other          .
                    errno = 0;
                    yylval.ival = strtol((char *)yytext,&endptr,10);
                    if (*endptr != '\0' || errno == ERANGE)
-                       elog(ERROR,"Bad integer input '%s'",yytext);
+                   {
+                       errno = 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);
+                   }
                    return (ICONST);
                }
 {real}/{space}*-{number} {
@@ -328,7 +336,7 @@ other           .
                    errno = 0;
                    yylval.dval = strtod(((char *)yytext),&endptr);
                    if (*endptr != '\0' || errno == ERANGE)
-                   elog(ERROR,"Bad float8 input '%s'",yytext);
+                       elog(ERROR,"Bad float8 input '%s'",yytext);
                    CheckFloat8Val(yylval.dval);
                    return (FCONST);
                }
@@ -338,7 +346,15 @@ other          .
                    errno = 0;
                    yylval.ival = strtol((char *)yytext,&endptr,10);
                    if (*endptr != '\0' || errno == ERANGE)
-                       elog(ERROR,"Bad integer input '%s'",yytext);
+                   {
+                       errno = 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);
+                   }
                    return (ICONST);
                }
 {real}         {