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

add support for [TRUNCATE|DISCARD|IMPORT|OPTIMIZE|REPAIR] PARTITION #453

Merged
merged 13 commits into from
Aug 15, 2019
Merged

add support for [TRUNCATE|DISCARD|IMPORT|OPTIMIZE|REPAIR] PARTITION #453

merged 13 commits into from
Aug 15, 2019

Conversation

huaouo
Copy link
Contributor

@huaouo huaouo commented Aug 10, 2019

What problem does this PR solve?

Fixes #432 #434 #436 #437 #439

  • MySQL Syntax:
alter_specification:
...
  | DISCARD PARTITION {partition_names | ALL} TABLESPACE
  | IMPORT PARTITION {partition_names | ALL} TABLESPACE
  | TRUNCATE PARTITION {partition_names | ALL}
  | OPTIMIZE PARTITION {partition_names | ALL}
  | REPAIR PARTITION {partition_names | ALL}
...

Add TRUNCATE PARTITION ALL clause.

What is changed and how it works?

  • Update ast/ddl.go, add some new AlterTableSpec types and modify Restore
  • Update parser.y.
  • Add more tests.

Check List

Tests

  • Unit test

@CLAassistant
Copy link

CLAassistant commented Aug 10, 2019

CLA assistant check
All committers have signed the CLA.

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

parser_test.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 10, 2019

Codecov Report

Merging #453 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #453      +/-   ##
==========================================
+ Coverage   71.24%   71.29%   +0.05%     
==========================================
  Files          32       32              
  Lines        7594     7587       -7     
==========================================
- Hits         5410     5409       -1     
+ Misses       1665     1662       -3     
+ Partials      519      516       -3
Impacted Files Coverage Δ
parser.go 70.58% <ø> (ø) ⬆️
misc.go 96.42% <ø> (ø) ⬆️
ast/ddl.go 79.67% <100%> (+0.56%) ⬆️
ast/misc.go 73.56% <0%> (-0.5%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1ba2994...27050dc. Read the comment docs.

@kennytm
Copy link
Contributor

kennytm commented Aug 10, 2019

PTAL @tangenta

ast/ddl.go Outdated Show resolved Hide resolved
parser.y Outdated Show resolved Hide resolved
@zier-one zier-one removed the status/LGT1 LGT1 label Aug 12, 2019
@zier-one zier-one changed the title add support for TRUNCATE PARTITION ALL add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION Aug 12, 2019
@huaouo huaouo changed the title add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION [WIP] add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION Aug 12, 2019
parser.y Outdated Show resolved Hide resolved
parser.y Outdated Show resolved Hide resolved
@spongedu
Copy link
Contributor

@huaouo There seems 2 shift/reduce conflicts encountered. you can grep conflict on to identify where indeed conflicts happens

@huaouo
Copy link
Contributor Author

huaouo commented Aug 13, 2019

@huaouo There seems 2 shift/reduce conflicts encountered. you can grep conflict on to identify where indeed conflicts happens

I'm sorry to bother you at midnight, but on my machine, there seems no such a problem. So wired.

➜  Workspace git clone https://github.com/huaouo/parser
Cloning into 'parser'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 2162 (delta 18), reused 23 (delta 13), pack-reused 2133
Receiving objects: 100% (2162/2162), 13.57 MiB | 279.00 KiB/s, done.
Resolving deltas: 100% (1603/1603), done.
➜  Workspace cd parser                                 
➜  parser git:(master) make test
gofmt (simplify)
sh test.sh
ok  	github.com/pingcap/parser	2.361s	coverage: 66.6% of statements in ./...
ok  	github.com/pingcap/parser/ast	1.422s	coverage: 44.8% of statements in ./...
ok  	github.com/pingcap/parser/auth	1.040s	coverage: 1.4% of statements in ./... [no tests to run]
ok  	github.com/pingcap/parser/charset	1.042s	coverage: 2.0% of statements in ./...
ok  	github.com/pingcap/parser/format	1.042s	coverage: 2.6% of statements in ./...
?   	github.com/pingcap/parser/goyacc	[no test files]
ok  	github.com/pingcap/parser/model	1.046s	coverage: 3.6% of statements in ./...
ok  	github.com/pingcap/parser/mysql	1.043s	coverage: 1.8% of statements in ./...
ok  	github.com/pingcap/parser/opcode	1.040s	coverage: 1.5% of statements in ./...
ok  	github.com/pingcap/parser/terror	1.040s	coverage: 2.4% of statements in ./...
ok  	github.com/pingcap/parser/types	1.048s	coverage: 7.3% of statements in ./...
➜  parser git:(master) git log -1 | head
commit ef08923e4d8e62fb1efba66716397bfe99fd8910
Author: Zhenhua Yang <huaouo@qq.com>
Date:   Tue Aug 13 23:18:18 2019 +0800

    add NO_WRITE_TO_BINLOG option for ALTER TABLE OPTIMIZE PARTITION & REPAIR PARTITION

@spongedu
Copy link
Contributor

@huaouo There seems 2 shift/reduce conflicts encountered. you can grep conflict on to identify where indeed conflicts happens

I'm sorry to bother you at midnight, but on my machine, there seems no such a problem. So wired.

➜  Workspace git clone https://github.com/huaouo/parser
Cloning into 'parser'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 2162 (delta 18), reused 23 (delta 13), pack-reused 2133
Receiving objects: 100% (2162/2162), 13.57 MiB | 279.00 KiB/s, done.
Resolving deltas: 100% (1603/1603), done.
➜  Workspace cd parser                                 
➜  parser git:(master) make test
gofmt (simplify)
sh test.sh
ok  	github.com/pingcap/parser	2.361s	coverage: 66.6% of statements in ./...
ok  	github.com/pingcap/parser/ast	1.422s	coverage: 44.8% of statements in ./...
ok  	github.com/pingcap/parser/auth	1.040s	coverage: 1.4% of statements in ./... [no tests to run]
ok  	github.com/pingcap/parser/charset	1.042s	coverage: 2.0% of statements in ./...
ok  	github.com/pingcap/parser/format	1.042s	coverage: 2.6% of statements in ./...
?   	github.com/pingcap/parser/goyacc	[no test files]
ok  	github.com/pingcap/parser/model	1.046s	coverage: 3.6% of statements in ./...
ok  	github.com/pingcap/parser/mysql	1.043s	coverage: 1.8% of statements in ./...
ok  	github.com/pingcap/parser/opcode	1.040s	coverage: 1.5% of statements in ./...
ok  	github.com/pingcap/parser/terror	1.040s	coverage: 2.4% of statements in ./...
ok  	github.com/pingcap/parser/types	1.048s	coverage: 7.3% of statements in ./...
➜  parser git:(master) git log -1 | head
commit ef08923e4d8e62fb1efba66716397bfe99fd8910
Author: Zhenhua Yang <huaouo@qq.com>
Date:   Tue Aug 13 23:18:18 2019 +0800

    add NO_WRITE_TO_BINLOG option for ALTER TABLE OPTIMIZE PARTITION & REPAIR PARTITION

Try to delete parser.go and execute make again?

spongedu
spongedu previously approved these changes Aug 14, 2019
Copy link
Contributor

@spongedu spongedu left a comment

Choose a reason for hiding this comment

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

LGTM

@spongedu
Copy link
Contributor

@huaouo Please resolve conflicts :)

parser.y Outdated Show resolved Hide resolved
@zier-one zier-one changed the title [WIP] add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION Aug 14, 2019
parser.y Outdated Show resolved Hide resolved
Co-Authored-By: leoppro <i@leop.pro>
@zier-one
Copy link
Contributor

LGTM

@zier-one zier-one added the status/LGT1 LGT1 label Aug 14, 2019
@zier-one
Copy link
Contributor

@kennytm PTAL

@huaouo
Copy link
Contributor Author

huaouo commented Aug 14, 2019

It seems there isn't an issue in the list about ANALYZE PARTITION, do I need to fix it? @leoppro

@zier-one
Copy link
Contributor

It seems there isn't an issue in the list about ANALYZE PARTITION, do I need to fix it? @leoppro

we needn't fix it

@huaouo
Copy link
Contributor Author

huaouo commented Aug 14, 2019

It seems there isn't an issue in the list about ANALYZE PARTITION, do I need to fix it? @leoppro

we needn't fix it

But according to MySQL's parser file, it also requires an opt_no_write_to_binlog option, same as ANALYZE TABLE stmt.

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

@kennytm kennytm added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Aug 14, 2019
@huaouo huaouo changed the title add support for [TRUNCATE|DISCARD|IMPORT|ANALYZE|OPTIMIZE|REPAIR] PARTITION add support for [TRUNCATE|DISCARD|IMPORT|OPTIMIZE|REPAIR] PARTITION Aug 14, 2019
@zier-one
Copy link
Contributor

It seems there isn't an issue in the list about ANALYZE PARTITION, do I need to fix it? @leoppro

we needn't fix it

But according to MySQL's parser file, it also requires an opt_no_write_to_binlog option, same as ANALYZE TABLE stmt.

Oh, I had a wrong understanding of your comment. We need to fix it.

@zier-one zier-one merged commit 15ebd4e into pingcap:master Aug 15, 2019
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix TRUNCATE PARTITION ALL syntax
5 participants