Skip to content

Commit

Permalink
plan: fix bug when access cond is not scalar function (pingcap#4044)
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros authored and shenli committed Aug 5, 2017
1 parent 6e0ff81 commit feecc6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ func (s *testSuite) TestSelectOrderBy(c *C) {
r.Check(testkit.Rows("2"))
r = tk.MustQuery("select b from (select a,b from t order by a,c limit 1) t")
r.Check(testkit.Rows("2"))

tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, index idx(a))")
tk.MustExec("insert into t values(1, 1), (2, 2)")
tk.MustQuery("select * from t where 1 order by b").Check(testkit.Rows("1 1", "2 2"))
}

func (s *testSuite) TestSelectErrorRow(c *C) {
Expand Down
5 changes: 4 additions & 1 deletion plan/new_physical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,10 @@ func (p *DataSource) convertToIndexScan(prop *requiredProp, idx *model.IndexInfo
if col.Name.L == prop.cols[0].ColName.L {
matchProperty = matchIndicesProp(idx.Columns[i:], prop.cols)
break
} else if i >= len(is.AccessCondition) || is.AccessCondition[i].(*expression.ScalarFunction).FuncName.L != ast.EQ {
} else if i >= len(is.AccessCondition) {
matchProperty = false
break
} else if sf, ok := is.AccessCondition[i].(*expression.ScalarFunction); !ok || sf.FuncName.L != ast.EQ {
matchProperty = false
break
}
Expand Down

0 comments on commit feecc6e

Please sign in to comment.