Skip to content

Commit e9dd03c

Browse files
committed
Minor code cleanups in pgbench expression support.
Get rid of unnecessary expr_yylex declaration (we haven't supported flex 2.5.4 in a long time, and even if we still did, the declaration in pgbench.h makes this one unnecessary and inappropriate). Fix copyright dates, improve some layout choices, etc.
1 parent 2c33e0f commit e9dd03c

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

contrib/pgbench/exprparse.y

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* exprparse.y
55
* bison grammar for a simple expression syntax
66
*
7-
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*-------------------------------------------------------------------------
@@ -36,9 +36,11 @@ static PgBenchExpr *make_op(char operator, PgBenchExpr *lexpr,
3636
%type <expr> expr
3737
%type <ival> INTEGER
3838
%type <str> VARIABLE
39+
3940
%token INTEGER VARIABLE
4041
%token CHAR_ERROR /* never used, will raise a syntax error */
4142

43+
/* Precedence: lowest to highest */
4244
%left '+' '-'
4345
%left '*' '/' '%'
4446
%right UMINUS

contrib/pgbench/exprscan.l

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* exprscan.l
55
* a lexical scanner for a simple expression syntax
66
*
7-
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*-------------------------------------------------------------------------
@@ -17,10 +17,6 @@ static int yyline = 0, yycol = 0;
1717
static YY_BUFFER_STATE scanbufhandle;
1818
static char *scanbuf;
1919
static int scanbuflen;
20-
21-
/* flex 2.5.4 doesn't bother with a decl for this */
22-
int expr_yylex(void);
23-
2420
%}
2521

2622
%option 8bit
@@ -32,7 +28,6 @@ int expr_yylex(void);
3228
%option warn
3329
%option prefix="expr_yy"
3430

35-
non_newline [^\n\r]
3631
space [ \t\r\f]
3732

3833
%%
@@ -44,15 +39,24 @@ space [ \t\r\f]
4439
"%" { yycol += yyleng; return '%'; }
4540
"(" { yycol += yyleng; return '('; }
4641
")" { yycol += yyleng; return ')'; }
47-
:[a-zA-Z0-9_]+ { yycol += yyleng; yylval.str = pg_strdup(yytext + 1); return VARIABLE; }
48-
[0-9]+ { yycol += yyleng; yylval.ival = strtoint64(yytext); return INTEGER; }
42+
43+
:[a-zA-Z0-9_]+ {
44+
yycol += yyleng;
45+
yylval.str = pg_strdup(yytext + 1);
46+
return VARIABLE;
47+
}
48+
[0-9]+ {
49+
yycol += yyleng;
50+
yylval.ival = strtoint64(yytext);
51+
return INTEGER;
52+
}
4953

5054
[\n] { yycol = 0; yyline++; }
51-
{space} { yycol += yyleng; /* ignore */ }
55+
{space}+ { yycol += yyleng; /* ignore */ }
5256

5357
. {
5458
yycol += yyleng;
55-
fprintf(stderr, "unexpected character '%s'\n", yytext);
59+
fprintf(stderr, "unexpected character \"%s\"\n", yytext);
5660
return CHAR_ERROR;
5761
}
5862
%%
@@ -64,7 +68,6 @@ yyerror(const char *message)
6468
* so the interesting location information is the column number */
6569
fprintf(stderr, "%s at column %d\n", message, yycol);
6670
/* go on to raise the error from pgbench with more information */
67-
/* exit(1); */
6871
}
6972

7073
/*

contrib/pgbench/pgbench.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* pgbench.h
44
*
5-
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
5+
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*-------------------------------------------------------------------------
@@ -18,7 +18,6 @@ typedef enum PgBenchExprType
1818
ENODE_OPERATOR
1919
} PgBenchExprType;
2020

21-
struct PgBenchExpr;
2221
typedef struct PgBenchExpr PgBenchExpr;
2322

2423
struct PgBenchExpr
@@ -53,4 +52,4 @@ extern void expr_scanner_finish(void);
5352

5453
extern int64 strtoint64(const char *str);
5554

56-
#endif
55+
#endif /* PGBENCH_H */

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