-
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 plan cache rebuild range error #42220
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. |
Skipping CI for Draft Pull Request. |
/retest |
3 similar comments
/retest |
/retest |
/retest |
planner/core/plan_cache.go
Outdated
@@ -662,6 +662,10 @@ func buildRangeForTableScan(sctx sessionctx.Context, ts *PhysicalTableScan) (err | |||
} | |||
|
|||
func buildRangeForIndexScan(sctx sessionctx.Context, is *PhysicalIndexScan) (err error) { | |||
if len(is.IdxCols) == 0 { // return full range when PhysicalIndexScan has no IdxCols | |||
is.Ranges = ranger.FullRange() |
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 IsFullRagne(is.Ranges) { // the original range is already a full-range.
return nil
} else {
return error("unexpected")
}
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.
@qw4990 Do you mean that we should assert IsFullRagne(is.Ranges)
must stand when len(is.IdxCols) == 0
?
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.
Yes, I'm not sure whether len(is.IdxCols)==0
can guarantee this is a IndexFullScan
, so check IsFullRagne(is.Ranges)
for safety.
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.
got it
@qw4990 @xuyifangreeneyes updated, TPAL again |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 67cc542
|
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
this bug won't affect 5.4 6.1 6.5, but we need cherry-pick a test to these version just for sure |
What problem does this PR solve?
Issue Number: close #42150
Problem Summary:
When rebuild range for
IndexFullScan
, if there is no filter on columns, the type slice may out of bound. There should be early stop logic facing this situation.What is changed and how it works?
Return full range when build index full scan without filter cols
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.