Skip to content

Commit

Permalink
cherry pick pingcap#25477 to release-5.1
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
zhuo-zhi authored and ti-srebot committed Jun 17, 2021
1 parent 4ca5d03 commit 2c68784
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions executor/point_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ func (s *testPointGetSuite) TestPointGetDataTooLong(c *C) {
tk.MustExec("drop table if exists PK_1389;")
}

// issue #25320
func (s *testPointGetSuite) TestDistinctPlan(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists test_distinct;")
tk.MustExec(`CREATE TABLE test_distinct (
id bigint(18) NOT NULL COMMENT '主键',
b bigint(18) NOT NULL COMMENT '用户ID',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;`)
tk.MustExec("insert into test_distinct values (123456789101112131,223456789101112131),(123456789101112132,223456789101112131);")
tk.MustQuery("select distinct b from test_distinct where id in (123456789101112131,123456789101112132);").Check(testkit.Rows("223456789101112131"))
}

func (s *testPointGetSuite) TestPointGetCharPK(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec(`use test;`)
Expand Down
2 changes: 1 addition & 1 deletion planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func newBatchPointGetPlan(

func tryWhereIn2BatchPointGet(ctx sessionctx.Context, selStmt *ast.SelectStmt) *BatchPointGetPlan {
if selStmt.OrderBy != nil || selStmt.GroupBy != nil ||
selStmt.Limit != nil || selStmt.Having != nil ||
selStmt.Limit != nil || selStmt.Having != nil || selStmt.Distinct ||
len(selStmt.WindowSpecs) > 0 {
return nil
}
Expand Down

0 comments on commit 2c68784

Please sign in to comment.