@@ -370,3 +370,32 @@ func TestPointGetForTemporaryTable(t *testing.T) {
370
370
tk .MustQuery ("select * from t1 where id = 1" ).Check (testkit .Rows ("1 1" ))
371
371
tk .MustQuery ("select * from t1 where id = 2" ).Check (testkit .Rows ())
372
372
}
373
+
374
+ func TestBatchPointGetIssue46779 (t * testing.T ) {
375
+ store := testkit .CreateMockStore (t )
376
+
377
+ tk := testkit .NewTestKit (t , store )
378
+ tk .MustExec ("use test" )
379
+ tk .MustExec ("drop table if exists t1" )
380
+ tk .MustExec ("CREATE TABLE t1 (id int, c varchar(128), primary key (id)) PARTITION BY HASH (id) PARTITIONS 3;" )
381
+ tk .MustExec (`insert into t1 values (1, "a"), (11, "b"), (21, "c")` )
382
+ query := "select * from t1 where id in (1, 1, 11)"
383
+ require .True (t , tk .HasPlan (query , "Batch_Point_Get" )) // check if BatchPointGet is used
384
+ tk .MustQuery (query ).Sort ().Check (testkit .Rows ("1 a" , "11 b" ))
385
+ query = "select * from t1 where id in (1, 11, 11, 21)"
386
+ require .True (t , tk .HasPlan (query , "Batch_Point_Get" )) // check if BatchPointGet is used
387
+ tk .MustQuery (query ).Sort ().Check (testkit .Rows ("1 a" , "11 b" , "21 c" ))
388
+
389
+ tk .MustExec ("drop table if exists t2" )
390
+ tk .MustExec (`CREATE TABLE t2 (id int, c varchar(128), primary key (id)) partition by range (id)(
391
+ partition p0 values less than (10),
392
+ partition p1 values less than (20),
393
+ partition p2 values less than (30));` )
394
+ tk .MustExec (`insert into t2 values (1, "a"), (11, "b"), (21, "c")` )
395
+ query = "select * from t2 where id in (1, 1, 11)"
396
+ require .True (t , tk .HasPlan (query , "Batch_Point_Get" )) // check if BatchPointGet is used
397
+ tk .MustQuery (query ).Sort ().Check (testkit .Rows ("1 a" , "11 b" ))
398
+ require .True (t , tk .HasPlan (query , "Batch_Point_Get" )) // check if BatchPointGet is used
399
+ query = "select * from t2 where id in (1, 11, 11, 21)"
400
+ tk .MustQuery (query ).Sort ().Check (testkit .Rows ("1 a" , "11 b" , "21 c" ))
401
+ }
0 commit comments