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

executor: fix IsPointGet judgment condition (#10278) #10304

Merged
merged 3 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,6 @@ func IsPointGetWithPKOrUniqueKeyByAutoCommit(ctx sessionctx.Context, p plan.Plan
case *plan.PhysicalIndexReader:
indexScan := v.IndexPlans[0].(*plan.PhysicalIndexScan)
return indexScan.IsPointGetByUniqueKey(ctx.GetSessionVars().StmtCtx), nil
case *plan.PhysicalIndexLookUpReader:
Copy link
Member

Choose a reason for hiding this comment

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

index lookup is not allowed to use point get?

Copy link
Member

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

It's more like a workaround other than a bugfix ..

Copy link
Member

Choose a reason for hiding this comment

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

This point get is not point get executor, it's using MaxTS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a bugfix... maybe the function name is a bit confusing...
index lookup is not allowed to use max ts and this function checks whether to use max ts
https://github.com/tiancaiamao/tidb/blob/ab1abb1938782f4bd69d15650489f9074e26ade6/executor/adapter.go#L312
@zz-jason

Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks

indexScan := v.IndexPlans[0].(*plan.PhysicalIndexScan)
return indexScan.IsPointGetByUniqueKey(ctx.GetSessionVars().StmtCtx), nil
case *plan.PhysicalTableReader:
tableScan := v.TablePlans[0].(*plan.PhysicalTableScan)
return len(tableScan.Ranges) == 1 && tableScan.Ranges[0].IsPoint(ctx.GetSessionVars().StmtCtx), nil
Expand Down
7 changes: 4 additions & 3 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,8 @@ func (s *testSuite) TestPointGet(c *C) {
tk.MustExec("use mysql")
ctx := tk.Se.(sessionctx.Context)
tests := map[string]bool{
"select * from help_topic where name='aaa'": true,
"select 1 from help_topic where name='aaa'": true,
"select * from help_topic where name='aaa'": false,
"select * from help_topic where help_topic_id=1": true,
"select * from help_topic where help_category_id=1": false,
}
Expand Down Expand Up @@ -2440,7 +2441,7 @@ func (s *testContextOptionSuite) TestCoprocessorPriority(c *C) {

cli.priority = pb.CommandPri_High
tk.MustQuery("select id from t where id = 1")
tk.MustQuery("select * from t1 where id = 1")
tk.MustQuery("select 1 from t1 where id = 1")

cli.priority = pb.CommandPri_Normal
tk.MustQuery("select count(*) from t")
Expand All @@ -2458,7 +2459,7 @@ func (s *testContextOptionSuite) TestCoprocessorPriority(c *C) {

cli.priority = pb.CommandPri_High
tk.MustQuery("select id from t where id = 1")
tk.MustQuery("select * from t1 where id = 1")
tk.MustQuery("select 1 from t1 where id = 1")

cli.priority = pb.CommandPri_Low
tk.MustQuery("select count(*) from t")
Expand Down