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

auto_inc,constraint: Ignore check constraint for auto-increment check #38966

Merged
merged 3 commits into from
Nov 10, 2022

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Nov 8, 2022

Signed-off-by: YangKeao [email protected]

What problem does this PR solve?

Issue Number: close #38894

Problem Summary:

While checking the auto-increment column is a key and iterating through the constraints, the check constraint doesn't have any key and return an error.

What is changed and how it works?

If the constraint is a check, just ignore it in this function.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Release note

Fix the issue that the auto increment column cannot be used with check constraint.

Signed-off-by: YangKeao <[email protected]>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 8, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • mjonss
  • 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 release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.3 size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 8, 2022
@YangKeao YangKeao changed the title planner: Ignore check constraint for auto-increment check auto_inc,constraint: Ignore check constraint for auto-increment check Nov 8, 2022
@@ -675,6 +675,10 @@ func checkAutoIncrementOp(colDef *ast.ColumnDef, index int) (bool, error) {

func isConstraintKeyTp(constraints []*ast.Constraint, colDef *ast.ColumnDef) bool {
Copy link
Contributor

@xhebox xhebox Nov 8, 2022

Choose a reason for hiding this comment

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

BTW, can we change the name of this function(or some comments)? I am worrying that somebody will use this function for non-auto-incr columns.

Copy link
Member Author

Choose a reason for hiding this comment

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

It returns whether the column is a constraint key.

I think it's fine to use it for other purpose, at least the change in this PR doesn't break it, because the CHECK constraint cannot be regarded as a key (and is not supported by TiDB, as described in the document) 🤔 .

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 8, 2022
Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

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

LGTM, with a minor question

tk.MustExec(`CREATE TABLE t (
id INTEGER NOT NULL AUTO_INCREMENT,
CHECK (id IN (0, 1)),
KEY idx_autoinc_id (id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this KEY needed?

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. The AUTO_INCREMENT column has to be defines as a key (any kind is fine).

@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 Nov 9, 2022
@YangKeao
Copy link
Member Author

@xhebox @mjonss If there is no more comments, could you help me to merge this PR?

@xiongjiwei
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 802e0cc

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 10, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #39043.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #39044.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #39045.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #39046.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #39047.

@sre-bot
Copy link
Contributor

sre-bot commented Nov 10, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [1] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-ddl-test 🔴 failed 1, success 5, total 6 44 min Existing failure
idc-jenkins-ci/integration-cdc-test 🔴 failed 1, success 38, total 39 19 min Existing failure
idc-jenkins-ci-tidb/mybatis-test 🔴 failed 1, success 0, total 1 11 min Existing failure
idc-jenkins-ci-tidb/sqllogic-test-2 ✅ all 28 tests passed 6 min 41 sec Fixed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 10 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 9 min 52 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 50 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 0 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 32 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

YangKeao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 15, 2022
YangKeao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 15, 2022
YangKeao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 15, 2022
YangKeao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 15, 2022
YangKeao added a commit to ti-chi-bot/tidb that referenced this pull request Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 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.

CREATE TABLE failed: ERROR 1105 (HY000): runtime error: index out if range [0] with length 0
6 participants