Skip to content

Commit 656ee84

Browse files
committed
Fix portability issues in 86c43f4.
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.
1 parent 5d4171d commit 656ee84

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/bin/pgbench/exprparse.y

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *
4747

4848
%type <elist> elist
4949
%type <expr> expr
50-
%type <ival> INTEGER function
51-
%type <dval> DOUBLE
50+
%type <ival> INTEGER_CONST function
51+
%type <dval> DOUBLE_CONST
5252
%type <str> VARIABLE FUNCTION
5353

54-
%token INTEGER DOUBLE VARIABLE FUNCTION
54+
%token INTEGER_CONST DOUBLE_CONST VARIABLE FUNCTION
5555

5656
/* Precedence: lowest to highest */
5757
%left '+' '-'
@@ -76,8 +76,8 @@ expr: '(' expr ')' { $$ = $2; }
7676
| expr '*' expr { $$ = make_op(yyscanner, "*", $1, $3); }
7777
| expr '/' expr { $$ = make_op(yyscanner, "/", $1, $3); }
7878
| expr '%' expr { $$ = make_op(yyscanner, "%", $1, $3); }
79-
| INTEGER { $$ = make_integer_constant($1); }
80-
| DOUBLE { $$ = make_double_constant($1); }
79+
| INTEGER_CONST { $$ = make_integer_constant($1); }
80+
| DOUBLE_CONST { $$ = make_double_constant($1); }
8181
| VARIABLE { $$ = make_variable($1); }
8282
| function '(' elist ')' { $$ = make_func(yyscanner, $1, $3); }
8383
;

src/bin/pgbench/exprscan.l

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ newline [\n]
123123
}
124124
{digit}+ {
125125
yylval->ival = strtoint64(yytext);
126-
return INTEGER;
126+
return INTEGER_CONST;
127127
}
128128
{digit}+(\.{digit}*)?([eE][-+]?{digit}+)? {
129-
yycolumn += yyleng;
130129
yylval->dval = atof(yytext);
131-
return DOUBLE;
130+
return DOUBLE_CONST;
131+
}
132+
\.{digit}+([eE][-+]?{digit}+)? {
133+
yylval->dval = atof(yytext);
134+
return DOUBLE_CONST;
132135
}
133136
{alpha}{alnum}* {
134137
yylval->str = pg_strdup(yytext);

src/bin/pgbench/pgbench.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ coerceToInt(PgBenchValue *pval, int64 *ival)
10431043
{
10441044
double dval = pval->u.dval;
10451045
Assert(pval->type == PGBT_DOUBLE);
1046-
if (dval < INT64_MIN || INT64_MAX < dval)
1046+
if (dval < PG_INT64_MIN || PG_INT64_MAX < dval)
10471047
{
10481048
fprintf(stderr, "double to int overflow for %f\n", dval);
10491049
return false;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy