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.h | |
parent | 1038bc91ca98865bd60bf63db46fc331f3099998 (diff) | |
download | postgresql-429ee5a822db0e8faf669d77c810f1eeaaff1ab4.tar.gz postgresql-429ee5a822db0e8faf669d77c810f1eeaaff1ab4.zip |
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.h')
-rw-r--r-- | src/bin/pgbench/pgbench.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h index c6aeb5b6dbd..ba2c51acc96 100644 --- a/src/bin/pgbench/pgbench.h +++ b/src/bin/pgbench/pgbench.h @@ -11,6 +11,15 @@ #ifndef PGBENCH_H #define PGBENCH_H +/* + * This file is included outside exprscan.l, in places where we can't see + * flex's definition of typedef yyscan_t. Fortunately, it's documented as + * being "void *", so we can use a macro to keep the function declarations + * here looking like the definitions in exprscan.l. exprparse.y also + * uses this to be able to declare things as "yyscan_t". + */ +#define yyscan_t void * + /* Types of expression nodes */ typedef enum PgBenchExprType { @@ -73,17 +82,18 @@ struct PgBenchExprList extern PgBenchExpr *expr_parse_result; -extern int expr_yyparse(void); -extern int expr_yylex(void); -extern void expr_yyerror(const char *str); -extern void expr_yyerror_more(const char *str, const char *more); -extern void expr_scanner_init(const char *str, const char *source, - const int lineno, const char *line, - const char *cmd, const int ecol); +extern int expr_yyparse(yyscan_t yyscanner); +extern int expr_yylex(yyscan_t yyscanner); +extern void expr_yyerror(yyscan_t yyscanner, const char *str); +extern void expr_yyerror_more(yyscan_t yyscanner, const char *str, + const char *more); +extern yyscan_t expr_scanner_init(const char *str, const char *source, + int lineno, const char *line, + const char *cmd, int ecol); extern void syntax_error(const char *source, const int lineno, const char *line, const char *cmd, const char *msg, const char *more, const int col); -extern void expr_scanner_finish(void); +extern void expr_scanner_finish(yyscan_t yyscanner); extern int64 strtoint64(const char *str); |