-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: fix uint type overflow on generated column not compatible with mysql | tidb-test=pr/2088 #40157
executor: fix uint type overflow on generated column not compatible with mysql | tidb-test=pr/2088 #40157
Conversation
[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 The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/cc @xiongjiwei |
/cc @wjhuang2016 |
executor/write_test.go
Outdated
@@ -4299,3 +4299,19 @@ func TestIssueInsertPrefixIndexForNonUTF8Collation(t *testing.T) { | |||
tk.MustExec("insert into t3 select 'abc '") | |||
tk.MustGetErrCode("insert into t3 select 'abc d'", 1062) | |||
} | |||
|
|||
func TestIssue40066(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more tests, for example, type char, decimal
table/column.go
Outdated
@@ -691,7 +691,9 @@ func FillVirtualColumnValue(virtualRetTypes []*types.FieldType, virtualColumnInd | |||
} | |||
// Because the expression might return different type from | |||
// the generated column, we should wrap a CAST on the result. | |||
sctx.GetSessionVars().StmtCtx.InFillVirtualColumnValue = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting it here may cause a data race. FillVirtualColumnValue() can be called concurrently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @wjhuang2016 , Can you give me some advice on how to fix it? The core reason is the "ShouldClipToZero",but i have no idea how to solve it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid there is not a clean way to do it. But we can add a particular check after CastValue() in FillVirtualColumnValue. We can check its type and value, then clip it to 0 if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wjhuang2016 i'm not very sure how to check it as you mentioned. After CastValue(),it should be a valiad destination type value already,how can judge it properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can know its type before CastValue(), and validate its value after CastValue(). If it doesn't obey the ShouldClipToZero
, then ClipToZero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will bring up the question about how to avoid the data race with regard to changing the sctx.GetSessionVars().StmtCtx.InFillVirtualColumnValue
in our team catchup.
Otherwise LGTM.
@jiyfhust: PR needs rebase. 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 kubernetes/test-infra repository. |
@wjhuang2016 @mjonss how about change this pr only solve the compatible error and warnings message? The select CastValue seems a little complex, an other pr to solve it specially? |
/cc @wjhuang2016 @mjonss |
/test check-dev |
/test mysql-test |
/test unit-test |
/retest |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: a86c7e7
|
/retest |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
What problem does this PR solve?
Issue Number: close #40066
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.