Fix portability issues in 86c43f4e22
.
INT64_MIN/MAX should be spelled PG_INT64_MIN/MAX, per well established convention in our sources. Less obviously, a symbol named DOUBLE causes problems on Windows builds, so rename that to DOUBLE_CONST; and rename INTEGER to INTEGER_CONST for consistency. Also, get rid of incorrect/obsolete hand-munging of yycolumn, and fix the grammar for float constants to handle expected cases such as ".1". First two items by Michael Paquier, second two by me.
This commit is contained in:
parent
5d4171d1c7
commit
656ee84890
|
@ -47,11 +47,11 @@ static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *
|
|||
|
||||
%type <elist> elist
|
||||
%type <expr> expr
|
||||
%type <ival> INTEGER function
|
||||
%type <dval> DOUBLE
|
||||
%type <ival> INTEGER_CONST function
|
||||
%type <dval> DOUBLE_CONST
|
||||
%type <str> VARIABLE FUNCTION
|
||||
|
||||
%token INTEGER DOUBLE VARIABLE FUNCTION
|
||||
%token INTEGER_CONST DOUBLE_CONST VARIABLE FUNCTION
|
||||
|
||||
/* Precedence: lowest to highest */
|
||||
%left '+' '-'
|
||||
|
@ -76,8 +76,8 @@ expr: '(' expr ')' { $$ = $2; }
|
|||
| expr '*' expr { $$ = make_op(yyscanner, "*", $1, $3); }
|
||||
| expr '/' expr { $$ = make_op(yyscanner, "/", $1, $3); }
|
||||
| expr '%' expr { $$ = make_op(yyscanner, "%", $1, $3); }
|
||||
| INTEGER { $$ = make_integer_constant($1); }
|
||||
| DOUBLE { $$ = make_double_constant($1); }
|
||||
| INTEGER_CONST { $$ = make_integer_constant($1); }
|
||||
| DOUBLE_CONST { $$ = make_double_constant($1); }
|
||||
| VARIABLE { $$ = make_variable($1); }
|
||||
| function '(' elist ')' { $$ = make_func(yyscanner, $1, $3); }
|
||||
;
|
||||
|
|
|
@ -123,12 +123,15 @@ newline [\n]
|
|||
}
|
||||
{digit}+ {
|
||||
yylval->ival = strtoint64(yytext);
|
||||
return INTEGER;
|
||||
return INTEGER_CONST;
|
||||
}
|
||||
{digit}+(\.{digit}*)?([eE][-+]?{digit}+)? {
|
||||
yycolumn += yyleng;
|
||||
yylval->dval = atof(yytext);
|
||||
return DOUBLE;
|
||||
return DOUBLE_CONST;
|
||||
}
|
||||
\.{digit}+([eE][-+]?{digit}+)? {
|
||||
yylval->dval = atof(yytext);
|
||||
return DOUBLE_CONST;
|
||||
}
|
||||
{alpha}{alnum}* {
|
||||
yylval->str = pg_strdup(yytext);
|
||||
|
|
|
@ -1043,7 +1043,7 @@ coerceToInt(PgBenchValue *pval, int64 *ival)
|
|||
{
|
||||
double dval = pval->u.dval;
|
||||
Assert(pval->type == PGBT_DOUBLE);
|
||||
if (dval < INT64_MIN || INT64_MAX < dval)
|
||||
if (dval < PG_INT64_MIN || PG_INT64_MAX < dval)
|
||||
{
|
||||
fprintf(stderr, "double to int overflow for %f\n", dval);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue