Fix portability issues in 86c43f4e22c0771fd0cc6bce2799802c894ee2ec.
authorTom Lane <[email protected]>
Tue, 29 Mar 2016 04:53:53 +0000 (00:53 -0400)
committerTom Lane <[email protected]>
Tue, 29 Mar 2016 04:53:53 +0000 (00:53 -0400)
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.

src/bin/pgbench/exprparse.y
src/bin/pgbench/exprscan.l
src/bin/pgbench/pgbench.c

index 877244852dd6eb007e779fab39bd81bf4d8a614e..64c29dcfa7b80966a9711bd47adfd9e8d934db7b 100644 (file)
@@ -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); }
        ;
index d8b706a99bcd28e2672d802ace1f155ed945f83b..20891a3b227b93de844f7889a1dba8a81477271a 100644 (file)
@@ -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);
index a2df4df20d9c06a92a3955336cc8acf4df12e6ac..4cd5513fc62538ce9f45c66125fb378e21141c01 100644 (file)
@@ -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;