-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MySQL (Oracle)] Cannot parse user variable in EXPLAIN INTO #4420
Comments
Good find @OnMYLai! |
Found another similar issue on NTILE call:
This runs fine and parses fine;
This can run, but parsing returns MySQL doc saids it is ok to use user-defined variables in NTILE call. Related rules: windowFunctionCall
: ...
| NTILE_SYMBOL (
OPEN_PAR_SYMBOL stableInteger CLOSE_PAR_SYMBOL
| {this.isServerVersionLt80024()}? simpleExprWithParentheses
) windowingClause
...
;
stableInteger
: int64Literal
| paramOrVar
;
paramOrVar
: PARAM_MARKER
| identifier
| AT_SIGN_SYMBOL textOrIdentifier
; P.S. I kept the server version used in parser as default 80200, if it was less than 80024 then the simpleExprWithParenthese will kick in and capture the @var without issue. |
Same issue MAYBE on TABLESAMPLE clause as well: tablesampleClause
: {this.isServerVersionGe80200()}? TABLESAMPLE_SYMBOL samplingMethod OPEN_PAR_SYMBOL samplingPercentage CLOSE_PAR_SYMBOL
;
samplingPercentage
: ulonglongNumber
| AT_SIGN_SYMBOL textOrIdentifier
| PARAM_MARKER
; I use MAYBE becoz
Anyway my testing SQL:
got me error |
The best option we have for this kind of problem is to compare the ANTLR grammar with the yacc grammar of the MySQL server. That's the ultimate source of truth. If the ANTLR grammar misses something it needs to be adjusted, otherwise that syntax is not allowed.
|
We already have a rule If it works just file a PR. |
My SQL, copying from MySQL doc with changes of the select sql to sth in my db:
EXPLAIN FORMAT=JSON INTO @myselect SELECT a FROM ab1;
Parsing return error msg
line 1:25 mismatched input '@myselect' expecting '@'
, and unable to parse the 'myselect' as an ID.the rule for the INTO part:
explainInto
: INTO_SYMBOL AT_SIGN_SYMBOL textOrIdentifier
;
maybe need to recognize AT_TEXT_SUFFIX?
The text was updated successfully, but these errors were encountered: