Skip to content
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

feat: add "HISTOGRAM" option in "ALTER TABLE... UPDATE/DROP..." #925

Merged
merged 2 commits into from
Sep 2, 2020

Conversation

wangggong
Copy link
Contributor

Signed-off-by: Wang Ruichao wangruichao2014@xiaochuankeji.cn

What problem does this PR solve?

Close #361 , cc pingcap/tidb#14800

Bad SQL:

ANALYZE TABLE `t1` UPDATE HISTOGRAM ON `b` WITH 1024 BUCKETS;

What is changed and how it works?

Add "ALTER TABLE... UPDATE/DROP HISTOGRAM" in parser.y, according to the document of mysql: https://dev.mysql.com/doc/refman/8.0/en/analyze-table.html

Check List

Tests

  • Unit test

@codecov
Copy link

codecov bot commented Jul 11, 2020

Codecov Report

Merging #925 into master will increase coverage by 0.02%.
The diff coverage is 94.11%.

@@            Coverage Diff             @@
##           master     #925      +/-   ##
==========================================
+ Coverage   78.43%   78.46%   +0.02%     
==========================================
  Files          40       40              
  Lines       14897    14805      -92     
==========================================
- Hits        11685    11617      -68     
+ Misses       2521     2501      -20     
+ Partials      691      687       -4     

ast/stats.go Outdated Show resolved Hide resolved
ast/stats.go Outdated Show resolved Hide resolved
ast/stats.go Outdated
@@ -90,6 +110,18 @@ func (n *AnalyzeTableStmt) Restore(ctx *format.RestoreCtx) error {
}
ctx.WriteName(partition.O)
}
if n.HistogramOperation != HistogramOperationNop {
ctx.WriteKeyWord(" " + HistogramOperationString[n.HistogramOperation] + " ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctx.WriteKeyWord(" " + HistogramOperationString[n.HistogramOperation] + " ")
ctx.WritePlain(" ")
ctx.WriteKeyWord(n.HistogramOperation.String())
ctx.WritePlain(" ")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done
thx a lot

parser_test.go Show resolved Hide resolved
Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-srebot
Copy link
Contributor

@kennytm,Thanks for your review.

Copy link
Contributor

@djshow832 djshow832 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the PR title wrong? It should be ANALYZE TABLE ... UPDATE / DROP ....
Besides, according to your PR description, why is ANALYZE TABLE t1UPDATE HISTOGRAM ONb WITH 1024 BUCKETS a bad sql?

@wangggong
Copy link
Contributor Author

Is the PR title wrong? It should be ANALYZE TABLE ... UPDATE / DROP ....
Besides, according to your PR description, why is ANALYZE TABLE t1UPDATE HISTOGRAM ONb WITH 1024 BUCKETS a bad sql?

Sorry for not explaining the title properly.

The situation is that there has been a statement ANALYZE TABLE ... UPDATE / DROP ..., which does not support HISTOGRAM option (so if the given bad SQL is parsed by the current parser, an error will be thrown); this PR supports it (according to the document in mysql shown in PR).

According to your comment, the title will be corrected.

@wangggong wangggong changed the title feat: add "ALTER TABLE... UPDATE/DROP HISTOGRAM" feat: add "HISTOGRAM" option in "ALTER TABLE... UPDATE/DROP..." Jul 18, 2020
@CLAassistant
Copy link

CLAassistant commented Sep 1, 2020

CLA assistant check
All committers have signed the CLA.

Wang Ruichao added 2 commits September 2, 2020 17:01
Signed-off-by: wangggong <793160615@qq.com>
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-srebot ti-srebot added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Sep 2, 2020
@tangenta tangenta merged commit c3f5fdd into pingcap:master Sep 2, 2020
@wangggong wangggong deleted the update_histogram branch September 2, 2020 10:09
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support ANALYZE TABLE .. UPDATE HISTOGRAM syntax
6 participants