diff --git a/executor/clustered_index_test.go b/executor/clustered_index_test.go index 86b67539e6d39..a3f2c322b2437 100644 --- a/executor/clustered_index_test.go +++ b/executor/clustered_index_test.go @@ -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`)") +} diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index bb2b282f8db9d..f4ae53819e42a 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -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