Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3899caf

Browse files
committed
Fix broken definition for function name in pgbench's exprscan.l.
As written, this would accept e.g. 123e9 as a function name. Aside from being mildly astonishing, that would come back to haunt us if we ever try to add float constants to the expression syntax. Insist that function names start with letters (or at least non-digits). In passing reset yyline as well as yycol when starting a new expression. This variable is useless since it's used nowhere, but if we're going to have it we should have it act sanely.
1 parent fd45d16 commit 3899caf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/bin/pgbench/exprscan.l

+8-5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ static int expr_col = 0;
3535
%option warn
3636
%option prefix="expr_yy"
3737

38+
alpha [a-zA-Z_]
39+
digit [0-9]
40+
alnum [a-zA-Z0-9_]
3841
space [ \t\r\f]
3942

4043
%%
@@ -48,17 +51,17 @@ space [ \t\r\f]
4851
")" { yycol += yyleng; return ')'; }
4952
"," { yycol += yyleng; return ','; }
5053

51-
:[a-zA-Z0-9_]+ {
54+
:{alnum}+ {
5255
yycol += yyleng;
5356
yylval.str = pg_strdup(yytext + 1);
5457
return VARIABLE;
5558
}
56-
[0-9]+ {
59+
{digit}+ {
5760
yycol += yyleng;
5861
yylval.ival = strtoint64(yytext);
5962
return INTEGER;
6063
}
61-
[a-zA-Z0-9_]+ {
64+
{alpha}{alnum}+ {
6265
yycol += yyleng;
6366
yylval.str = pg_strdup(yytext);
6467
return FUNCTION;
@@ -107,8 +110,8 @@ expr_scanner_init(const char *str, const char *source,
107110
expr_command = (char *) cmd;
108111
expr_col = (int) ecol;
109112

110-
/* reset column count for this scan */
111-
yycol = 0;
113+
/* reset error pointers for this scan */
114+
yycol = yyline = 0;
112115

113116
/*
114117
* Might be left over after error

0 commit comments

Comments
 (0)