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

txn: change check logic for column type change for amend #22150

Merged
merged 4 commits into from
Jan 6, 2021

Conversation

cfzjywxk
Copy link
Contributor

@cfzjywxk cfzjywxk commented Jan 4, 2021

What problem does this PR solve?

Issue Number: close #21470

Problem Summary:
On the 5.0 or the master branch, the change column ddl may NOT keep the original column id as in the release-4.0 branch, checking the modify colum action type in amend phase could not decide whether it's a newly added column or if this column type change is accepatable, so report error for such branches.

What is changed and how it works?

What's Changed:
Report error for checking modify colum action type if the column could not be found in early schema version though column type change is not GA release currently. This change will make the amend fail for ddl change with both adding column and modifying column.

How it Works:

Related changes

Check List

Tests

  • Unit test

Side effects

Release note

  • No release note`.

@cfzjywxk cfzjywxk added type/bugfix This PR fixes a bug. sig/transaction SIG:Transaction labels Jan 4, 2021
@cfzjywxk cfzjywxk changed the title txn: add check for column type change for amend txn: change check logic for column type change for amend Jan 4, 2021
// is newly added or modified from an original column.Report error to solve the issue
// https://github.com/pingcap/tidb/issues/21470. This change will make amend fail for adding column
// and modifying columns at the same time.
return nil, errors.Trace(errors.Errorf("column=%v id=%v is not found for table=%v checking column modify",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to make add-column amend fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Single add-column will not fail, change type containing add column with modify/change column will.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that errors.Errorf will attach stack info, thus I think errors.Trace is unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the function's comment at L193 needs to be updated?

@ichn-hu ichn-hu mentioned this pull request Jan 4, 2021
@lysu
Copy link
Contributor

lysu commented Jan 5, 2021

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 5, 2021
@cfzjywxk cfzjywxk force-pushed the amend_with_col_type_change branch from 7cdfb07 to 2978a3d Compare January 5, 2021 05:36
@cfzjywxk cfzjywxk force-pushed the amend_with_col_type_change branch from 2978a3d to c8d1457 Compare January 5, 2021 12:51
Copy link
Member

@jackysp jackysp 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 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 6, 2021
@cfzjywxk
Copy link
Contributor Author

cfzjywxk commented Jan 6, 2021

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 6, 2021
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 67da69b into pingcap:master Jan 6, 2021
@cfzjywxk cfzjywxk deleted the amend_with_col_type_change branch January 6, 2021 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/transaction SIG:Transaction status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Amending transaction accepts DDLs that changes column types but gives wrong result
7 participants