pingcap / parser

A MySQL Compatible SQL Parser
Apache License 2.0
1.41k stars 489 forks source link

Support add/drop attributes for table or partition #1271

Closed rleungx closed 3 years ago

rleungx commented 3 years ago

What problem does this PR solve?

It's used for the region label feature. Closes https://github.com/pingcap/parser/issues/1288.

What is changed and how it works?

This PR is going to support

ALTER TABLE t ATTRIBUTES="attr1,attr2,...,attrn"
ALTER TABLE t PARTITION p ATTRIBUTES="attr1,attr2,...,attrn"

to change the attributes of a table or a partition.

And use the following syntax to reset all attributes for a table or a partition:

ALTER TABLE t ATTRIBUTES=default
ALTER TABLE t PARTITION p ATTRIBUTES=default

Check List

Tests

Related changes

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

kennytm commented 3 years ago

what is the difference between this and PLACEMENT POLICY?

rleungx commented 3 years ago

what is the difference between this and PLACEMENT POLICY?

We are going to add some attributes to a table/partition to solve some specified problems. e.g., notmerge attribute means don't merge a table. It's different from the placement rule which mainly focuses on data placement.

tangenta commented 3 years ago

@rleungx We may also need to consider the removal syntax for attributes. Anyway, it would be better if there is a detailed design document.

rleungx commented 3 years ago

PTAL @djshow832 @xhebox, thanks.

rleungx commented 3 years ago

@rleungx We may also need to consider the removal syntax for attributes. Anyway, it would be better if there is a detailed design document.

How about using alter table t attributes=default for removing all attributes?

ti-chi-bot commented 3 years ago

[REVIEW NOTIFICATION]

This pull request has been approved by:

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 commented 3 years ago

@nolouch: 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](https://github.com/pingcap/parser/pull/1271#pullrequestreview-716592323): >lgtm Instructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.
djshow832 commented 3 years ago

/merge

ti-chi-bot commented 3 years ago

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

Commit hash: 89383726756dd410c26600229e5ed7f85345b618