@@ -306,6 +306,54 @@ func TestUnionScanForMemBufferReader(t *testing.T) {
306
306
tk .MustExec ("admin check table t1;" )
307
307
}
308
308
309
+ func TestIssue53951 (t * testing.T ) {
310
+ store := testkit .CreateMockStore (t )
311
+ tk := testkit .NewTestKit (t , store )
312
+ tk .MustExec ("use test" )
313
+ tk .MustExec (`CREATE TABLE gholla_dummy1 (
314
+ id varchar(10) NOT NULL,
315
+ mark int,
316
+ deleted_at datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
317
+ account_id varchar(10) NOT NULL,
318
+ metastore_id varchar(10) NOT NULL,
319
+ is_deleted tinyint(1) GENERATED ALWAYS AS ((deleted_at > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
320
+ PRIMARY KEY (account_id,metastore_id,id),
321
+ KEY isDeleted_accountId_metastoreId (is_deleted,account_id,metastore_id)
322
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;` )
323
+ tk .MustExec (`CREATE TABLE gholla_dummy2 (
324
+ id varchar(10) NOT NULL,
325
+ mark int,
326
+ deleted_at datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
327
+ account_id varchar(10) NOT NULL,
328
+ metastore_id varchar(10) NOT NULL,
329
+ is_deleted tinyint(1) GENERATED ALWAYS AS ((deleted_at > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
330
+ PRIMARY KEY (account_id,metastore_id,id),
331
+ KEY isDeleted_accountId_metastoreId (is_deleted,account_id,metastore_id)
332
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; ` )
333
+ tk .MustExec (`INSERT INTO gholla_dummy1 (id,mark,deleted_at,account_id,metastore_id) VALUES ('ABC', 1, '1970-01-01 01:00:01.000', 'ABC', 'ABC');` )
334
+ tk .MustExec (`INSERT INTO gholla_dummy2 (id,mark,deleted_at,account_id,metastore_id) VALUES ('ABC', 1, '1970-01-01 01:00:01.000', 'ABC', 'ABC');` )
335
+ tk .MustExec (`start transaction;` )
336
+ tk .MustExec (`update gholla_dummy2 set deleted_at = NOW(), mark=2 where account_id = 'ABC' and metastore_id = 'ABC' and id = 'ABC';` )
337
+ tk .MustQuery (`select
338
+ /*+ INL_JOIN(g1, g2) */
339
+ g1.account_id,
340
+ g2.mark
341
+ from
342
+ gholla_dummy1 g1 FORCE INDEX(isDeleted_accountId_metastoreId)
343
+ STRAIGHT_JOIN
344
+ gholla_dummy2 g2 FORCE INDEX (PRIMARY)
345
+ ON
346
+ g1.account_id = g2.account_id AND
347
+ g1.metastore_id = g2.metastore_id AND
348
+ g1.id = g2.id
349
+ WHERE
350
+ g1.account_id = 'ABC' AND
351
+ g1.metastore_id = 'ABC' AND
352
+ g1.is_deleted = FALSE AND
353
+ g2.is_deleted = FALSE;` ).Check (testkit .Rows ()) // empty result, no error
354
+ tk .MustExec (`rollback` )
355
+ }
356
+
309
357
func TestForUpdateUntouchedIndex (t * testing.T ) {
310
358
store := testkit .CreateMockStore (t )
311
359
tk := testkit .NewTestKit (t , store )
0 commit comments