@@ -3218,3 +3218,46 @@ func TestAuthSocket(t *testing.T) {
3218
3218
ts .CheckRows (t , rows , "u2@%" )
3219
3219
})
3220
3220
}
3221
+
3222
+ func TestBatchGetTypeForRowExpr (t * testing.T ) {
3223
+ ts := servertestkit .CreateTidbTestSuite (t )
3224
+
3225
+ // single columns
3226
+ ts .RunTests (t , nil , func (dbt * testkit.DBTestKit ) {
3227
+ dbt .MustExec ("use test;" )
3228
+ dbt .MustExec ("create table t1 (id varchar(255) collate utf8mb4_general_ci, primary key (id));" )
3229
+ dbt .MustExec ("insert into t1 values ('a'), ('c');" )
3230
+
3231
+ conn , err := dbt .GetDB ().Conn (context .Background ())
3232
+ require .NoError (t , err )
3233
+ defer func () {
3234
+ require .NoError (t , conn .Close ())
3235
+ }()
3236
+ _ , err = conn .ExecContext (context .Background (), "set @@session.collation_connection = 'utf8mb4_general_ci'" )
3237
+ require .NoError (t , err )
3238
+ stmt , err := conn .PrepareContext (context .Background (), "select * from t1 where id in (?, ?)" )
3239
+ require .NoError (t , err )
3240
+ rows , err := stmt .Query ("A" , "C" )
3241
+ require .NoError (t , err )
3242
+ ts .CheckRows (t , rows , "a\n c" )
3243
+ })
3244
+
3245
+ // multiple columns
3246
+ ts .RunTests (t , nil , func (dbt * testkit.DBTestKit ) {
3247
+ dbt .MustExec ("use test;" )
3248
+ dbt .MustExec ("create table t2 (id1 varchar(255) collate utf8mb4_general_ci, id2 varchar(255) collate utf8mb4_general_ci, primary key (id1, id2));" )
3249
+ dbt .MustExec ("insert into t2 values ('a', 'b'), ('c', 'd');" )
3250
+
3251
+ conn , err := dbt .GetDB ().Conn (context .Background ())
3252
+ require .NoError (t , err )
3253
+ defer func () {
3254
+ require .NoError (t , conn .Close ())
3255
+ }()
3256
+ conn .ExecContext (context .Background (), "set @@session.collation_connection = 'utf8mb4_general_ci'" )
3257
+ stmt , err := conn .PrepareContext (context .Background (), "select * from t2 where (id1, id2) in ((?, ?), (?, ?))" )
3258
+ require .NoError (t , err )
3259
+ rows , err := stmt .Query ("A" , "B" , "C" , "D" )
3260
+ require .NoError (t , err )
3261
+ ts .CheckRows (t , rows , "a b\n c d" )
3262
+ })
3263
+ }
0 commit comments