Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9dd03c

Browse files
committed
Minor code cleanups in pgbench expression support.
Get rid of unnecessary expr_yylex declaration (we haven't supportedflex 2.5.4 in a long time, and even if we still did, the declaration inpgbench.h makes this one unnecessary and inappropriate). Fix copyrightdates, improve some layout choices, etc.
1 parent2c33e0f commite9dd03c

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
%tokenINTEGERVARIABLE
4041
%tokenCHAR_ERROR/* never used, will raise a syntax error*/
4142

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

‎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 intyyline = 0, yycol = 0;
1717
static YY_BUFFER_STATE scanbufhandle;
1818
staticchar *scanbuf;
1919
staticintscanbuflen;
20-
21-
/* flex 2.5.4 doesn't bother with a decl for this*/
22-
intexpr_yylex(void);
23-
2420
%}
2521

2622
%option8bit
@@ -32,7 +28,6 @@ int expr_yylex(void);
3228
%optionwarn
3329
%optionprefix="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-
structPgBenchExpr;
2221
typedefstructPgBenchExprPgBenchExpr;
2322

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

5453
externint64strtoint64(constchar*str);
5554

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp