Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Mar 20, 2017
1 parent 9a9ae32 commit ef178a3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plan/physical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,16 @@ func buildIndexScanByKeyAndCorCol(p *DataSource, idx *model.IndexInfo, fakeConds
fakeAccessConditions, restFakeConds := detachIndexScanConditions(fakeConds, is)
accessConditions := make([]expression.Expression, 0, len(fakeAccessConditions))
restOrigConds := make([]expression.Expression, 0, len(restFakeConds))
// accessConditions is not in original order. So we could only use brute force there.
for i := 0; i < len(fakeConds); i++ {
for _, cond := range fakeAccessConditions {
if fakeConds[i].Equal(cond, p.ctx) {
accessConditions = append(accessConditions, origConds[i])
} else {
restOrigConds = append(restOrigConds, origConds[i])
}
}
}
for i, j := 0, 0; i < len(fakeConds); {
if j < len(fakeAccessConditions) && fakeConds[i].Equal(fakeAccessConditions[j], p.ctx) {
accessConditions = append(accessConditions, origConds[i])
Expand Down Expand Up @@ -962,8 +972,12 @@ func (p *Selection) getUsableIndicesAndPk(ds *DataSource) ([]*model.IndexInfo, m
for i, col := range ds.Columns {
if mysql.HasPriKeyFlag(col.Flag) {
pkCol = ds.schema.Columns[i]
break
}
}
if pkCol == nil {
return usableIdxs, pkName
}
checker := conditionChecker{
pkName: pkCol.ColName,
length: types.UnspecifiedLength,
Expand Down

0 comments on commit ef178a3

Please sign in to comment.