-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
planner: fix index join on unmatched collation suffix columns paniced #24828
planner: fix index join on unmatched collation suffix columns paniced #24828
Conversation
@wjhuang2016 PTAL, I'm not very sure about this change - - |
@@ -1272,6 +1272,7 @@ func (ijHelper *indexJoinBuildHelper) removeUselessEqAndInFunc(idxCols []*expres | |||
ijHelper.curPossibleUsedKeys = append(ijHelper.curPossibleUsedKeys, idxCols[idxColPos]) | |||
continue | |||
} | |||
ijHelper.curIdxOff2KeyOff[idxColPos] = -1 |
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.
Why we did this change? Or should we strengthen the case to STRING
type only?
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.
if we didn't change this
for table t1 (a int not null, b varcharbinary not null,index (a, b))
and t2(a int not null, b varchar not null, index(a, b))
the query: 't1 join t2 on t1. a = tb2.a and t2.a = t2.b'
will cause ranges
only contain column a
's value(caused by https://github.com/pingcap/tidb/pull/21201...not use the column if collation isn't matched), but keyOff2IdxOff
include both a
and b
's offset in
Line 3677 in bfdad7c
for keyOff, idxOff := range keyOff2IdxOff { |
so the query will panic
@winoros is any other advise to fix this~? I'm not familiar with those part logic 😂
@winoros PTAL if free thx... |
The logic around this function is:
The For this the issue to be fixed in the pr. The collation check for the column is a little later. We'd better add the check earlier at https://github.com/pingcap/tidb/blob/master/planner/core/exhaust_physical_plans.go#L1219. |
Also, i think we'd better check the collation after we checked the column type is a STRING type. /cc @wjhuang2016 |
@winoros @wjhuang2016 PTAL if free thx~ |
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
[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. |
/merge |
@lysu: 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. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 3883bd6
|
/run-check_dev_2 |
/run-integration-common-test |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-5.1 in PR #25436 |
What problem does this PR solve?
Issue Number: close #24706
Problem Summary:
index join on a, b, but b's collation is not matched, b's curIdxOff2KeyOff not be set to -1?
What is changed and how it works?
What's Changed, How it Works:
index join on a, b, but b's collation is not matched, we should only build range (a)
Related changes
Check List
Tests
Side effects
Release note