-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
parser: support OPTIMIZE
statement
#49205
Conversation
Welcome @ub-3! |
Hi @ub-3. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @ub-3. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@ub-3: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #49205 +/- ##
================================================
+ Coverage 71.0504% 72.0487% +0.9983%
================================================
Files 1368 1406 +38
Lines 402168 413226 +11058
================================================
+ Hits 285742 297724 +11982
- Misses 96553 96714 +161
+ Partials 19873 18788 -1085
Flags with carried forward coverage won't be shown. Click here to find out more.
|
It would be confusing to TiDB users when 'OPTIMIZE TABLE' is accepted but does nothing. Do you have any specific requirement to have this supported in syntax only? |
I agree that since this PR changes the behaviour for user, we need to discuss what's the expected behaviour for TiDB of Maybe If you only care about the parser's golang API, you can still let TiDB report error for OPTIMIZE. |
@bb7133 To be honest, I'm only interested in parser support. I should read MySQL slow-logs and analyzes queries, and your package is just what I need. I'm not so familiar with the project, but it seems to me, given that the parser used to be in a separate project, adding this support is not such an issue. |
Can you explain what it means? I won't like to add edits that break the API, is there an example of how this can be avoided? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but probably something is needed in TiDB code to either implement it or to block/fail it. With current patch it will just say OK, without any checks for table etc.
tidb> drop table if exists t;
Query OK, 0 rows affected, 1 warning (0.00 sec)
tidb> show warnings;
+-------+------+------------------------+
| Level | Code | Message |
+-------+------+------------------------+
| Note | 1051 | Unknown table 'test.t' |
+-------+------+------------------------+
1 row in set (0.00 sec)
tidb> optimize table t;
Query OK, 0 rows affected (0.01 sec)
@mjonss What about this kind of message ?
This can be done by handling the statement as follows. pkg/planner/core/planbuilder.go:819
...
case *ast.OptimizeTableStmt:
return nil, ErrNotSupportedYet.GenWithStackByArgs("OPTIMIZE")
... |
Yes, something like that. Since we moved the parser into the TiDB repository, we also need to update the rest of TiDB code to handle new changes in the parser (which is the normal case). I also think that generating the error in
|
@mjonss Thanks for the good explanation! |
OPTIMIZE
statement.OPTIMIZE
statement | tidb-test=pr/2261
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Need update a private repo to pass mysql-tester, which I have done. https://github.com/PingCAP-QE/tidb-test/pull/2261
[LGTM Timeline notifier]Timeline:
|
I holding this PR, so we can merge it with the matching PR for passing the mysql-tester CI test. |
@yudongusa or @easonn7 can you approve this PR, it adds OPTIMIZE TABLE to the parser, and also blocks it in the TiDB code, so the statement will show 'OPTIMIZE TABLE is not supported' instead of a parser error. |
This looks good. However it should have set some of the items in the description as this affects mysql compatibility, user behavior and syntax (all of them in a positive way). |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Defined2014, easonn7, mjonss, tangenta The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
/test mysql-test |
@Defined2014: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
OPTIMIZE
statement | tidb-test=pr/2261OPTIMIZE
statement
/test mysql-test |
@Defined2014: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test mysql-test |
@Defined2014: The specified target(s) for
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
OPTIMIZE
statementOPTIMIZE
statement | tidb-test=pr/2261
OPTIMIZE
statement | tidb-test=pr/2261OPTIMIZE
statement
/retest |
/retest |
What problem does this PR solve?
Now it is possible to parse SQL with OPTIMIZE statement.
Issue Number: close #49204
Problem Summary: There is no support for the
OPTIMIZE
statementWhat changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.