From: Tom Lane Date: Mon, 7 Mar 2016 02:04:25 +0000 (-0500) Subject: Fix broken definition for function name in pgbench's exprscan.l. X-Git-Tag: REL9_6_BETA1~582 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3899caf772c8dec5c79e553c91f8fc248ca686c9;p=postgresql 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. --- diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l index df673f09f2..cb51a98fd6 100644 --- a/src/bin/pgbench/exprscan.l +++ b/src/bin/pgbench/exprscan.l @@ -35,6 +35,9 @@ static int expr_col = 0; %option warn %option prefix="expr_yy" +alpha [a-zA-Z_] +digit [0-9] +alnum [a-zA-Z0-9_] space [ \t\r\f] %% @@ -48,17 +51,17 @@ space [ \t\r\f] ")" { yycol += yyleng; return ')'; } "," { yycol += yyleng; return ','; } -:[a-zA-Z0-9_]+ { +:{alnum}+ { yycol += yyleng; yylval.str = pg_strdup(yytext + 1); return VARIABLE; } -[0-9]+ { +{digit}+ { yycol += yyleng; yylval.ival = strtoint64(yytext); return INTEGER; } -[a-zA-Z0-9_]+ { +{alpha}{alnum}+ { yycol += yyleng; yylval.str = pg_strdup(yytext); return FUNCTION; @@ -107,8 +110,8 @@ expr_scanner_init(const char *str, const char *source, expr_command = (char *) cmd; expr_col = (int) ecol; - /* reset column count for this scan */ - yycol = 0; + /* reset error pointers for this scan */ + yycol = yyline = 0; /* * Might be left over after error