diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-19 16:35:41 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-19 16:35:41 -0400 |
commit | 429ee5a822db0e8faf669d77c810f1eeaaff1ab4 (patch) | |
tree | 60b96ede0aed5ad8511e197741060a185894f001 /src/bin/pgbench/pgbench.c | |
parent | 1038bc91ca98865bd60bf63db46fc331f3099998 (diff) |
Make pgbench's expression lexer reentrant.
This is a necessary preliminary step for making it play with psqlscan.l
given the way I set up the lexer input-buffer sharing mechanism in commit
0ea9efbe9ec1bf07.
I've not tried to make it *actually* reentrant; there's still some static
variables laying about. But flex thinks it's reentrant, and that's what
counts.
In support of that, fix exprparse.y to pass through the yyscan_t from the
caller. Also do some minor code beautification, like not casting away
const.
Diffstat (limited to 'src/bin/pgbench/pgbench.c')
-rw-r--r-- | src/bin/pgbench/pgbench.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 4606fb00158..dab1ed4114e 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -2495,17 +2495,22 @@ process_commands(char *buf, const char *source, const int lineno) } else if (pg_strcasecmp(my_commands->argv[0], "set") == 0) { + yyscan_t yyscanner; + if (my_commands->argc < 3) { syntax_error(source, lineno, my_commands->line, my_commands->argv[0], "missing argument", NULL, -1); } - expr_scanner_init(my_commands->argv[2], source, lineno, - my_commands->line, my_commands->argv[0], - my_commands->cols[2] - 1); + yyscanner = expr_scanner_init(my_commands->argv[2], + source, + lineno, + my_commands->line, + my_commands->argv[0], + my_commands->cols[2] - 1); - if (expr_yyparse() != 0) + if (expr_yyparse(yyscanner) != 0) { /* dead code: exit done from syntax_error called by yyerror */ exit(1); @@ -2513,7 +2518,7 @@ process_commands(char *buf, const char *source, const int lineno) my_commands->expr = expr_parse_result; - expr_scanner_finish(); + expr_scanner_finish(yyscanner); } else if (pg_strcasecmp(my_commands->argv[0], "sleep") == 0) { |