Skip to content

Commit c912fd3

Browse files
committed
Fixes of MDEV-30538 and MDEV-30586 for 10.4 adjusted for 11.0.
The commits for MDEV-30538 and MDEV-30586 could not be cherry-picked into 11.0 separately.
1 parent 554278e commit c912fd3

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

mysql-test/main/delete.result

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ explain delete from t1
583583
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
584584
id select_type table type possible_keys key key_len ref rows Extra
585585
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
586-
2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 8 Using where
586+
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
587+
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
587588
delete from t1
588589
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3;
589590
select *from t1;
@@ -599,7 +600,8 @@ where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
599600
order by c2;
600601
id select_type table type possible_keys key key_len ref rows Extra
601602
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
602-
2 DEPENDENT SUBQUERY a ALL NULL NULL NULL NULL 8 Using where
603+
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
604+
2 MATERIALIZED a ALL NULL NULL NULL NULL 8
603605
delete from t1
604606
where exists (select 'X' from t1 a where a.c2 = t1.c2) and c2 >= 3
605607
order by c2;

mysql-test/main/multi_update.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,7 @@ EXPLAIN
12691269
DROP TABLES t1, t2;
12701270
# End of 10.3 tests
12711271
#
1272-
# MDEV-28538: multi-table UPDATE/DELETE with possible exists-to-in
1273-
#
1272+
# MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
12741273
create table t1 (c1 int, c2 int, c3 int, index idx(c2));
12751274
insert into t1 values
12761275
(1,1,1),(3,2,2),(1,3,3),

mysql-test/main/multi_update.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ DROP TABLES t1, t2;
11351135
--echo # End of 10.3 tests
11361136

11371137
--echo #
1138-
--echo # MDEV-28538: multi-table UPDATE/DELETE with possible exists-to-in
1138+
--echo # MDEV-30538: multi-table UPDATE/DELETE with possible exists-to-in
11391139
--echo #
11401140

11411141
create table t1 (c1 int, c2 int, c3 int, index idx(c2));

sql/item_subselect.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,9 @@ bool Item_exists_subselect::select_prepare_to_be_in()
29532953
if (!optimizer &&
29542954
(thd->lex->sql_command == SQLCOM_SELECT ||
29552955
thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
2956-
thd->lex->sql_command == SQLCOM_DELETE_MULTI) &&
2956+
thd->lex->sql_command == SQLCOM_DELETE_MULTI ||
2957+
thd->lex->sql_command == SQLCOM_UPDATE ||
2958+
thd->lex->sql_command == SQLCOM_DELETE) &&
29572959
!unit->first_select()->is_part_of_union() &&
29582960
optimizer_flag(thd, OPTIMIZER_SWITCH_EXISTS_TO_IN) &&
29592961
(is_top_level_item() ||

sql/sql_yacc.yy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13374,14 +13374,15 @@ delete_part2:
1337413374
{
1337513375
LEX *lex= Lex;
1337613376
lex->last_table()->vers_conditions= lex->vers_conditions;
13377-
lex->pop_select(); //main select
1337813377
lex->sql_command= SQLCOM_DELETE;
1337913378
if (!(lex->m_sql_cmd=
1338013379
new (thd->mem_root) Sql_cmd_delete(false)))
1338113380
MYSQL_YYABORT;
1338213381
if (lex->check_main_unit_semantics())
1338313382
MYSQL_YYABORT;
1338413383
}
13384+
stmt_end
13385+
{}
1338513386
;
1338613387

1338713388
delete_single_table:
@@ -13432,14 +13433,14 @@ single_multi:
1343213433
LEX *lex= Lex;
1343313434
if ($3)
1343413435
Select->order_list= *($3);
13435-
lex->pop_select(); //main select
1343613436
lex->sql_command= SQLCOM_DELETE;
1343713437
if (!(lex->m_sql_cmd=
1343813438
new (thd->mem_root) Sql_cmd_delete(false)))
1343913439
MYSQL_YYABORT;
1344013440
if (Lex->check_main_unit_semantics())
1344113441
MYSQL_YYABORT;
1344213442
}
13443+
stmt_end {}
1344313444
| table_alias_ref_list
1344413445
{
1344513446
LEX *lex= Lex;

0 commit comments

Comments
 (0)