Skip to content

Commit

Permalink
planner: clustered index support primary index hint (pingcap#18478)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored Jul 10, 2020
1 parent af129d2 commit 563f2c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions executor/clustered_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ func (s *testClusteredSuite) TestClusteredTopN(c *C) {
tk.MustExec("insert o3 values (1, 6, 9, 3), (2, 6, 9, 5), (3, 6, 9, 7)")
tk.MustQuery("SELECT max(o_id) max_order FROM o3 use index (idx_order)").Check(testkit.Rows("3"))
}

func (s *testClusteredSuite) TestClusteredHint(c *C) {
tk := s.newTK(c)
tk.MustExec("drop table if exists ht")
tk.MustExec("create table ht (a varchar(64) primary key, b int)")
tk.MustQuery("select * from ht use index (`PRIMARY`)")
}
2 changes: 1 addition & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ func getPathByIndexName(paths []*util.AccessPath, idxName model.CIStr, tblInfo *
return path
}
}
if isPrimaryIndex(idxName) && tblInfo.PKIsHandle {
if isPrimaryIndex(idxName) && (tblInfo.PKIsHandle || tblInfo.IsCommonHandle) {
return tablePath
}
return nil
Expand Down

0 comments on commit 563f2c9

Please sign in to comment.