summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2023-05-08 11:42:24 -0700
committerIgor Babaev <igor@askmonty.org>2023-05-08 11:42:24 -0700
commita09f661f4392fc9574a5239972243eebc65fe7f2 (patch)
treec463c4ded62447c51a2045ee0b6c14d275db5a2a /sql/opt_subselect.cc
parent84b9fc25a29b94a37eb9d5ac2e2c0f75c0efafda (diff)
downloadmariadb-git-a09f661f4392fc9574a5239972243eebc65fe7f2.tar.gz
MDEV-31181 Crash with EXPLAIN EXTENDED for single-table DELETE using IN predicand
This bug affected EXPLAIN EXTENDED command for single-table DELETE that used an IN subquery in its WHERE clause. A crash happened if the optimizer chose to employ index_subquery or unique_subquery access when processing such command. The crash happened when the command tried to print the transformed query. In the current code of 10.4 for single-table DELETE statements the output of any explain command is produced after the join structures of all used subqueries have been destroyed. JOIN::destroy() sets the field tab of the JOIN_TAB structures created for subquery tables to NULL. As a result subselect_indexsubquery_engine::print(), subselect_indexsubquery_engine() cannot use this field to get the alias name of the joined table. This patch suggests to use the field TABLE_LIST::TAB that can be accessed from JOIN_TAB::tab_list to get the alias name of the joined table. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 1c03b0bb4a3..db7a4c0fc14 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -4128,6 +4128,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm->materialized= FALSE;
sjm_tab->table= sjm->table;
+ sjm_tab->tab_list= emb_sj_nest;
sjm->table->pos_in_table_list= emb_sj_nest;
DBUG_RETURN(FALSE);