Commit 8d21a6ef authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Keep long non-quoted numeric strings *as* untyped strings if they fail

 the obvious conversion.
Define a new pattern "decimal" which is non-exponential floating point
 for use with numeric() and decimal() types.
parent a36a7a16
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.48 1999/05/03 19:09:42 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.49 1999/05/12 07:12:51 thomas Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
#endif #endif
#define YY_READ_BUF_SIZE MAX_PARSE_BUFFER #define YY_READ_BUF_SIZE MAX_PARSE_BUFFER
#ifdef YY_READ_BUF_SIZE
#undef YY_READ_BUF_SIZE
#endif
#define YY_READ_BUF_SIZE MAX_PARSE_BUFFER
extern char *parseString; extern char *parseString;
static char *parseCh; static char *parseCh;
...@@ -157,10 +162,11 @@ operator {op_and_self}+ ...@@ -157,10 +162,11 @@ operator {op_and_self}+
xmstop - xmstop -
integer [\-]?{digit}+ integer [\-]?{digit}+
decimal [\-]?(({digit}*\.{digit}+)|({digit}+\.{digit}*))
real [\-]?((({digit}*\.{digit}+)|({digit}+\.{digit}*)|({digit}+))([Ee][-+]?{digit}+))
/* /*
real [\-]?{digit}+\.{digit}+([Ee][-+]?{digit}+)?
*/
real [\-]?(((({digit}*\.{digit}+)|({digit}+\.{digit}*))([Ee][-+]?{digit}+)?)|({digit}+[Ee][-+]?{digit}+)) real [\-]?(((({digit}*\.{digit}+)|({digit}+\.{digit}*))([Ee][-+]?{digit}+)?)|({digit}+[Ee][-+]?{digit}+))
*/
param \${integer} param \${integer}
...@@ -339,15 +345,35 @@ other . ...@@ -339,15 +345,35 @@ other .
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
{ {
errno = 0; errno = 0;
#if 0
yylval.dval = strtod(((char *)yytext),&endptr); 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); CheckFloat8Val(yylval.dval);
elog(NOTICE,"Integer input '%s' is out of range; promoted to float", yytext); elog(NOTICE,"Integer input '%s' is out of range; promoted to float", yytext);
return FCONST; return FCONST;
#endif
yylval.str = pstrdup((char*)yytext);
return SCONST;
} }
return ICONST; return ICONST;
} }
{decimal}/{space}*-{number} {
char* endptr;
BEGIN(xm);
if (strlen((char *)yytext) <= 17)
{
errno = 0;
yylval.dval = strtod(((char *)yytext),&endptr);
if (*endptr != '\0' || errno == ERANGE)
elog(ERROR,"Bad float8 input '%s'",yytext);
CheckFloat8Val(yylval.dval);
return FCONST;
}
yylval.str = pstrdup((char*)yytext);
return SCONST;
}
{real}/{space}*-{number} { {real}/{space}*-{number} {
char* endptr; char* endptr;
...@@ -367,15 +393,34 @@ other . ...@@ -367,15 +393,34 @@ other .
if (*endptr != '\0' || errno == ERANGE) if (*endptr != '\0' || errno == ERANGE)
{ {
errno = 0; errno = 0;
#if 0
yylval.dval = strtod(((char *)yytext),&endptr); 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); CheckFloat8Val(yylval.dval);
elog(NOTICE,"Integer input '%s' is out of range; promoted to float", yytext); elog(NOTICE,"Integer input '%s' is out of range; promoted to float", yytext);
return FCONST; return FCONST;
#endif
yylval.str = pstrdup((char*)yytext);
return SCONST;
} }
return ICONST; 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;
}
{real} { {real} {
char* endptr; char* endptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment