summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2020-05-11 19:56:14 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2020-05-14 23:24:10 +0530
commitefd68f5e3184c54e04045a1350a1ff37dc313348 (patch)
treef0ec0452ce0dd20f2bec25fa68233835bb974ee2 /sql/item_subselect.cc
parentee5152fc4bc0f164d546ce87c1d36d1a5f78591b (diff)
downloadmariadb-git-efd68f5e3184c54e04045a1350a1ff37dc313348.tar.gz
MDEV-22498: SIGSEGV in Bitmap<64u>::merge on SELECT
For the case when the optimizer does the IN-EXISTS transformation, the equality condition is injected in the WHERE OR HAVING clause of the subquery. If the select list of the subquery has a reference to the parent select make sure to use the reference and not the original item.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index e3cb82df170..16ef8a192c5 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -2135,10 +2135,13 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
}
else
{
+ /*
+ No need to use real_item for the item, as the ref items that are possible
+ in the subquery either belong to views or to the parent select.
+ For such case we need to refer to the reference and not to the original
+ item.
+ */
Item *item= (Item*) select_lex->item_list.head();
- if (item->type() != REF_ITEM ||
- ((Item_ref*)item)->ref_type() != Item_ref::VIEW_REF)
- item= item->real_item();
if (select_lex->table_list.elements)
{