Open qw4990 opened 3 years ago
Any options about this requirement? @zz-jason @eurekaka @winoros Since it is not complex and urgent, we can ask some contributors to implement this feature if it is accepted.
@qw4990 Question from a new comer here.
I tried to take a look into parser.y
and it seems that we may have a few solutions
Either add ExecuteStmt into ExplainableStmt. This looks neats, but not sure if it is valid, as not all executable statements are explainable. Moreover, there are tons of shift/reduce conflicts to deal with in this case.
Do a customize:
| ExplainSym "ANALYZE" ExecuteStmt
{
$$ = &ast.ExplainStmt{
Stmt: $3,
Format: "row",
Analyze: true,
}
}
OR
| ExplainSym ExecuteStmt { $$ = &ast.ExplainStmt{ Stmt: $2, Format: "row", } }
This approach works, however, it will duplicate a bit of code in `parse.y`
Another question since I do not totally understand:
`ExplainSym "ANALYZE" ExecuteStmt` does not generate any shift/reduce conflict, but `ExplainSym ExecuteStmt` does. Do you have any suggestion ? I am quite blocked in this point, there must be something I miss. My best guess is that there is something to do with the `Identifier` argument in the definition of `ExecuteStmt`
ExecuteStmt: "EXECUTE" Identifier { $$ = &ast.ExecuteStmt{Name: $2} }
It seems that adding any valid keyword between `ExplainSym` and `ExecuteStmt` solves the shift/conflict problem (which is the case of `ExplainSym "ANALYZE" ExecuteStmt`. But I still do not understand why.
ExplainSym "ANALYZE" ExecuteStmt
does not generate any shift/reduce conflict, butExplainSym ExecuteStmt
does. Do you have any suggestion ? I am quite blocked in this point, there must be something I miss. My best guess is that there is something to do with theIdentifier
argument in the definition ofExecuteStmt
ExecuteStmt: "EXECUTE" Identifier { $$ = &ast.ExecuteStmt{Name: $2} }
It seems that adding any valid keyword between
ExplainSym
andExecuteStmt
solves the shift/conflict problem (which is the case ofExplainSym "ANALYZE" ExecuteStmt
. But I still do not understand why.
It seems that ExplainSym ExecuteStmt
is ambiguous , as it is translated to EXPLAIN EXECUTE Identifier
and Identifier
can be anything from reserved to non reserved keyword, which is indeed ambiguous . I will try to address this issue in the PR
can i pick this up?
can i pick this up?
I don't have time to continue any further unfortunately, so feel free to grab. No objection for my side .
Feature Request
Is your feature request related to a problem? Please describe:
Explain and explain analyze statements can print query plans, which is useful when optimizing queries and investigating issues, but prepared queries cannot support this feature:
Describe the feature you'd like:
Support explain and explain analyze statements for prepared queries, for example:
Describe alternatives you've considered:
To get plans of prepared statements, now we can use
explain for {ConnID}
or search them fromslow log file
, but both these two methods are not convenient.Teachability, Documentation, Adoption, Migration Strategy: