@@ -2322,6 +2322,68 @@ func TestIssue48257(t *testing.T) {
2322
2322
))
2323
2323
}
2324
2324
2325
+ func TestIssue54870 (t * testing.T ) {
2326
+ store := testkit .CreateMockStore (t )
2327
+ tk := testkit .NewTestKit (t , store )
2328
+
2329
+ tk .MustExec ("use test" )
2330
+ tk .MustExec (`create table t (id int,
2331
+ deleted_at datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
2332
+ is_deleted tinyint(1) GENERATED ALWAYS AS ((deleted_at > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
2333
+ key k(id, is_deleted))` )
2334
+ tk .MustExec (`begin` )
2335
+ tk .MustExec (`insert into t (id, deleted_at) values (1, now())` )
2336
+ tk .MustHavePlan (`select 1 from t where id=1 and is_deleted=true` , "IndexRangeScan" )
2337
+ }
2338
+
2339
+ func TestIssue53951 (t * testing.T ) {
2340
+ store := testkit .CreateMockStore (t )
2341
+ tk := testkit .NewTestKit (t , store )
2342
+ tk .MustExec ("use test" )
2343
+ tk .MustExec (`CREATE TABLE gholla_dummy1 (
2344
+ id varchar(10) NOT NULL,
2345
+ mark int,
2346
+ deleted_at datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
2347
+ account_id varchar(10) NOT NULL,
2348
+ metastore_id varchar(10) NOT NULL,
2349
+ is_deleted tinyint(1) GENERATED ALWAYS AS ((deleted_at > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
2350
+ PRIMARY KEY (account_id,metastore_id,id),
2351
+ KEY isDeleted_accountId_metastoreId (is_deleted,account_id,metastore_id)
2352
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;` )
2353
+ tk .MustExec (`CREATE TABLE gholla_dummy2 (
2354
+ id varchar(10) NOT NULL,
2355
+ mark int,
2356
+ deleted_at datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
2357
+ account_id varchar(10) NOT NULL,
2358
+ metastore_id varchar(10) NOT NULL,
2359
+ is_deleted tinyint(1) GENERATED ALWAYS AS ((deleted_at > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
2360
+ PRIMARY KEY (account_id,metastore_id,id),
2361
+ KEY isDeleted_accountId_metastoreId (is_deleted,account_id,metastore_id)
2362
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; ` )
2363
+ 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');` )
2364
+ 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');` )
2365
+ tk .MustExec (`start transaction;` )
2366
+ tk .MustExec (`update gholla_dummy2 set deleted_at = NOW(), mark=2 where account_id = 'ABC' and metastore_id = 'ABC' and id = 'ABC';` )
2367
+ tk .MustQuery (`select
2368
+ /*+ INL_JOIN(g1, g2) */
2369
+ g1.account_id,
2370
+ g2.mark
2371
+ from
2372
+ gholla_dummy1 g1 FORCE INDEX(isDeleted_accountId_metastoreId)
2373
+ STRAIGHT_JOIN
2374
+ gholla_dummy2 g2 FORCE INDEX (PRIMARY)
2375
+ ON
2376
+ g1.account_id = g2.account_id AND
2377
+ g1.metastore_id = g2.metastore_id AND
2378
+ g1.id = g2.id
2379
+ WHERE
2380
+ g1.account_id = 'ABC' AND
2381
+ g1.metastore_id = 'ABC' AND
2382
+ g1.is_deleted = FALSE AND
2383
+ g2.is_deleted = FALSE;` ).Check (testkit .Rows ()) // empty result, no error
2384
+ tk .MustExec (`rollback` )
2385
+ }
2386
+
2325
2387
func TestIssue52472 (t * testing.T ) {
2326
2388
store := testkit .CreateMockStore (t )
2327
2389
tk := testkit .NewTestKit (t , store )
0 commit comments