Skip to content
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

plan: always clone Expression when set it to plan. #6263

Merged
merged 6 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions executor/join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ func (s *testSuite) TestJoin(c *C) {
result = tk.MustQuery("select /*+ TIDB_HJ(s, r) */ * from t as s join t as r on s.a = r.a limit 1;")
result.Check(testkit.Rows("1 1"))
plan.JoinConcurrency = savedConcurrency

tk.MustExec("drop table if exists user, aa, bb")
tk.MustExec("create table aa(id int)")
tk.MustExec("insert into aa values(1)")
tk.MustExec("create table bb(id int)")
tk.MustExec("insert into bb values(1)")
tk.MustExec("create table user(id int, name varchar(20))")
tk.MustExec("insert into user values(1, 'a'), (2, 'b')")
tk.MustQuery("select user.id,user.name from user left join aa on aa.id = user.id left join bb on aa.id = bb.id where bb.id < 10;").Check(testkit.Rows("1 a"))
}

func (s *testSuite) TestJoinCast(c *C) {
Expand Down
10 changes: 8 additions & 2 deletions plan/predicate_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,14 @@ func (p *LogicalJoin) PredicatePushDown(predicates []expression.Expression) (ret
case InnerJoin:
p.LeftConditions = nil
p.RightConditions = nil
p.EqualConditions = equalCond
p.OtherConditions = otherCond
p.EqualConditions = make([]*expression.ScalarFunction, 0, len(equalCond))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p.EqualConditions = make([]*expression.ScalarFunction, len(equalCond)) ?

We need fulfill expression later anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this change affect too much?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to use append.
We don't need to think if make full length is applicable, we can safely use append.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't change as much. It is just neat to use the way I proposed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yes. It's perfect fine to use append.

for _, cond := range equalCond {
p.EqualConditions = append(p.EqualConditions, cond.Clone().(*expression.ScalarFunction))
}
p.OtherConditions = make([]expression.Expression, 0, len(otherCond))
for _, cond := range otherCond {
p.OtherConditions = append(p.OtherConditions, cond.Clone())
}
leftCond = leftPushCond
rightCond = rightPushCond
}
Expand Down