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

ddl: support alter table attributes to add a label rule #26511

Merged
merged 9 commits into from
Jul 30, 2021

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jul 23, 2021

What problem does this PR solve?

Closes #26692.

This PR is going to support

ALTER TABLE t ATTRIBUTES="xxx"

to add an attribute for a table.

What is changed and how it works?

What's Changed:

  1. add a new type AlterTableAttributes in AlterTable.
  2. introduce a new struct Rule which is the same as LabelRule defined in PD
  3. support synchronizing a new rule to PD.

Check List

Tests

  • Unit test (need more unit tests)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 23, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 23, 2021
@rleungx rleungx force-pushed the alter-table-attribute branch from 48263c2 to dc5941c Compare July 23, 2021 09:05
@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jul 23, 2021
@nolouch nolouch requested review from nolouch, Yisaer and xhebox July 23, 2021 09:32
ddl/label/attributes.go Outdated Show resolved Hide resolved
ddl/ddl_api.go Outdated Show resolved Hide resolved
ddl/label/attributes_test.go Outdated Show resolved Hide resolved
ddl/label/attributes_test.go Outdated Show resolved Hide resolved

// ResetTable will reset the label rule for a table with a given ID and names.
func (r *Rule) ResetTable(id int64, dbName, tableName string) *Rule {
r.ID = fmt.Sprintf(TableIDFormat, IDPrefix, dbName, tableName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that text ID is troublesome for rename table, and flashback/recover where you only get the integer. You will need history job and model out of ddl package to retrieve the name.
.
Check #20575 for gc and placement rules.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. And I have worked on it in the last few days.

ddl/label/rule.go Show resolved Hide resolved
ddl/label/attributes.go Outdated Show resolved Hide resolved
ddl/label/rule.go Show resolved Hide resolved
@rleungx rleungx force-pushed the alter-table-attribute branch 2 times, most recently from baf2d78 to ad5bcee Compare July 27, 2021 03:17
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 27, 2021
@nolouch
Copy link
Member

nolouch commented Jul 28, 2021

PTAL @JmPotato

Copy link
Member

@JmPotato JmPotato left a comment

Choose a reason for hiding this comment

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

Rest LGTM.

ddl/label/attributes.go Outdated Show resolved Hide resolved
ddl/label/attributes.go Outdated Show resolved Hide resolved
domain/infosync/info.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Jul 28, 2021
@rleungx rleungx force-pushed the alter-table-attribute branch 5 times, most recently from bdae5e5 to 5c1e5ad Compare July 28, 2021 08:20
@rleungx rleungx requested a review from xhebox July 28, 2021 08:25
@github-actions github-actions bot added the sig/execution SIG execution label Jul 28, 2021
@rleungx
Copy link
Member Author

rleungx commented Jul 28, 2021

/run-check_dev_2

@ti-chi-bot
Copy link
Member

@JmPotato: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

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 ti-community-infra/tichi repository.

ddl/ddl_api.go Outdated Show resolved Hide resolved
func NewLabels(attrs []string) Labels {
labels := make(Labels, 0, len(attrs))
for _, attr := range attrs {
label := NewLabel(attr)
Copy link
Member

Choose a reason for hiding this comment

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

should valid the attributes? only supports nomerge at present.

@rleungx rleungx force-pushed the alter-table-attribute branch from af5bf87 to 3f9b5c8 Compare July 29, 2021 02:25
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 29, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2021
@nolouch
Copy link
Member

nolouch commented Jul 30, 2021

/run-check_dev_2

Copy link
Contributor

@Yisaer Yisaer 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-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 30, 2021
@Yisaer
Copy link
Contributor

Yisaer commented Jul 30, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 6ab0df62efcbad72a20335afc80bb0de1f94de8f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 30, 2021
rleungx added 7 commits July 30, 2021 14:55
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
@rleungx rleungx force-pushed the alter-table-attribute branch from abeeec8 to 7e20f79 Compare July 30, 2021 07:47
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Jul 30, 2021
@Yisaer
Copy link
Contributor

Yisaer commented Jul 30, 2021

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 7e20f79

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 30, 2021
@rleungx
Copy link
Member Author

rleungx commented Jul 30, 2021

/run-unit-test

1 similar comment
@rleungx
Copy link
Member Author

rleungx commented Jul 30, 2021

/run-unit-test

@ti-chi-bot
Copy link
Member

@rleungx: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 30, 2021
@rleungx
Copy link
Member Author

rleungx commented Jul 30, 2021

/run-check_dev_2

@ti-chi-bot ti-chi-bot merged commit 17523d3 into pingcap:master Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support alter table attributes to add label rules
6 participants