From c7b13ef1af3250c20546ed21965054a4d66b731c Mon Sep 17 00:00:00 2001 From: Han Fei Date: Fri, 5 Jan 2018 23:47:33 +0800 Subject: [PATCH] plan: refine code. (#5565) --- plan/physical_plan_builder.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plan/physical_plan_builder.go b/plan/physical_plan_builder.go index 5f6d4dc68b887..4e8676c33fb17 100644 --- a/plan/physical_plan_builder.go +++ b/plan/physical_plan_builder.go @@ -392,9 +392,8 @@ func (ds *DataSource) convertToIndexScan(prop *requiredProp, idx *model.IndexInf return task, nil } -// TODO: refine this. func (is *PhysicalIndexScan) initSchema(id int, idx *model.IndexInfo, isDoubleRead bool) { - var indexCols []*expression.Column + indexCols := make([]*expression.Column, 0, len(idx.Columns)) for _, col := range idx.Columns { indexCols = append(indexCols, &expression.Column{FromID: id, Position: col.Offset}) } @@ -455,13 +454,9 @@ func matchIndicesProp(idxCols []*model.IndexColumn, propCols []*expression.Colum func splitIndexFilterConditions(conditions []expression.Expression, indexColumns []*model.IndexColumn, table *model.TableInfo) (indexConds, tableConds []expression.Expression) { var pkName model.CIStr - if table.PKIsHandle { - for _, colInfo := range table.Columns { - if mysql.HasPriKeyFlag(colInfo.Flag) { - pkName = colInfo.Name - break - } - } + pkInfo := table.GetPkColInfo() + if pkInfo != nil { + pkName = pkInfo.Name } var indexConditions, tableConditions []expression.Expression for _, cond := range conditions {