diff options
| author | Tom Lane | 2016-03-21 01:59:03 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-03-21 01:59:03 +0000 |
| commit | b6afae71aaf6d2df76d0a0a77c8b630220a01ec1 (patch) | |
| tree | 97c0b1f7427fd7133b10ac5c3437beae10f30400 /src/bin/psql | |
| parent | 6f1f34c92b11593ec62ff3e12781eb96dc911821 (diff) | |
Use %option bison-bridge in psql/pgbench lexers.
The point of this change is to use %pure-parser in pgbench's exprparse.y.
The immediate reason is that it turns out very ancient versions of bison
have a bug with the combination of a reentrant lexer and non-reentrant
parser. We could consider dropping support for such ancient bisons; but
considering that we might well need exprparse.y to be reentrant some day,
it seems better to make it so right now than to move the portability
goalposts. (AFAICT there's no particular performance consequence to this
change, either, so there's no good reason not to do it.)
Now, %pure-parser assumes that the called lexer is built with %option
bison-bridge. Because we're assuming bitwise compatibility of yyscan_t
(yyguts_t) data structures among all the psql/pgbench lexers, that
requirement propagates back to psql's lexers as well. But it's just a
few lines of change on that side too; and if psqlscan.l is to set the
baseline for a possibly-large family of lexers, it should err on the
side of including not omitting useful features.
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/psqlscan.l | 9 | ||||
| -rw-r--r-- | src/bin/psql/psqlscanslash.l | 14 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l index 26ad45c7f98..93c73559602 100644 --- a/src/bin/psql/psqlscan.l +++ b/src/bin/psql/psqlscan.l @@ -36,6 +36,12 @@ #include "psqlscan_int.h" /* + * We must have a typedef YYSTYPE for yylex's first argument, but this lexer + * doesn't presently make use of that argument, so just declare it as int. + */ +typedef int YYSTYPE; + +/* * Set the type of yyextra; we use it as a pointer back to the containing * PsqlScanState. */ @@ -64,6 +70,7 @@ extern void psql_yyset_column(int column_no, yyscan_t yyscanner); %} %option reentrant +%option bison-bridge %option 8bit %option never-interactive %option nodefault @@ -1002,7 +1009,7 @@ psql_scan(PsqlScanState state, yy_switch_to_buffer(state->scanbufhandle, state->scanner); /* And lex. */ - lexresult = yylex(state->scanner); + lexresult = yylex(NULL, state->scanner); /* * Check termination state and return appropriate result info. diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index e3cef7c5c5d..a89ce15ad4c 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -27,6 +27,12 @@ #include "psqlscan_int.h" /* + * We must have a typedef YYSTYPE for yylex's first argument, but this lexer + * doesn't presently make use of that argument, so just declare it as int. + */ +typedef int YYSTYPE; + +/* * Set the type of yyextra; we use it as a pointer back to the containing * PsqlScanState. */ @@ -62,7 +68,9 @@ extern void slash_yyset_column(int column_no, yyscan_t yyscanner); %} +/* Except for the prefix, these options should match psqlscan.l */ %option reentrant +%option bison-bridge %option 8bit %option never-interactive %option nodefault @@ -447,7 +455,7 @@ psql_scan_slash_command(PsqlScanState state) state->start_state = xslashcmd; /* And lex. */ - yylex(state->scanner); + yylex(NULL, state->scanner); /* There are no possible errors in this lex state... */ @@ -521,7 +529,7 @@ psql_scan_slash_option(PsqlScanState state, state->start_state = xslashargstart; /* And lex. */ - lexresult = yylex(state->scanner); + lexresult = yylex(NULL, state->scanner); /* Save final state for a moment... */ final_state = state->start_state; @@ -648,7 +656,7 @@ psql_scan_slash_command_end(PsqlScanState state) state->start_state = xslashend; /* And lex. */ - yylex(state->scanner); + yylex(NULL, state->scanner); /* There are no possible errors in this lex state... */ |
