Skip to content
Snippets Groups Projects
Commit 3899caf7 authored by Tom Lane's avatar Tom Lane
Browse files

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.
parent fd45d16f
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,9 @@ static int expr_col = 0; ...@@ -35,6 +35,9 @@ static int expr_col = 0;
%option warn %option warn
%option prefix="expr_yy" %option prefix="expr_yy"
alpha [a-zA-Z_]
digit [0-9]
alnum [a-zA-Z0-9_]
space [ \t\r\f] space [ \t\r\f]
%% %%
...@@ -48,17 +51,17 @@ space [ \t\r\f] ...@@ -48,17 +51,17 @@ space [ \t\r\f]
")" { yycol += yyleng; return ')'; } ")" { yycol += yyleng; return ')'; }
"," { yycol += yyleng; return ','; } "," { yycol += yyleng; return ','; }
:[a-zA-Z0-9_]+ { :{alnum}+ {
yycol += yyleng; yycol += yyleng;
yylval.str = pg_strdup(yytext + 1); yylval.str = pg_strdup(yytext + 1);
return VARIABLE; return VARIABLE;
} }
[0-9]+ { {digit}+ {
yycol += yyleng; yycol += yyleng;
yylval.ival = strtoint64(yytext); yylval.ival = strtoint64(yytext);
return INTEGER; return INTEGER;
} }
[a-zA-Z0-9_]+ { {alpha}{alnum}+ {
yycol += yyleng; yycol += yyleng;
yylval.str = pg_strdup(yytext); yylval.str = pg_strdup(yytext);
return FUNCTION; return FUNCTION;
...@@ -107,8 +110,8 @@ expr_scanner_init(const char *str, const char *source, ...@@ -107,8 +110,8 @@ expr_scanner_init(const char *str, const char *source,
expr_command = (char *) cmd; expr_command = (char *) cmd;
expr_col = (int) ecol; expr_col = (int) ecol;
/* reset column count for this scan */ /* reset error pointers for this scan */
yycol = 0; yycol = yyline = 0;
/* /*
* Might be left over after error * Might be left over after error
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment