Skip to content

Commit

Permalink
Update plan_cache.go
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzf678 committed Mar 15, 2023
1 parent 19a881a commit 82283ae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions planner/core/plan_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,15 @@ 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()
return
if len(is.IdxCols) == 0 {
if ranger.HasFullRange(is.Ranges, false) { // the original range is already a full-range.
is.Ranges = ranger.FullRange()
return
} else {
return errors.New("unexpected range for PhysicalIndexScan")
}
}

res, err := ranger.DetachCondAndBuildRangeForIndex(sctx, is.AccessCondition, is.IdxCols, is.IdxColLens, 0)
if err != nil {
return err
Expand Down

0 comments on commit 82283ae

Please sign in to comment.