summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-05-10 13:01:42 +0200
committerSergei Golubchik <serg@mariadb.org>2018-05-10 13:01:42 +0200
commit9b1824dcd2564c803e58d02ac63b49ec68bd60d2 (patch)
treebeef3faf3e0e6b8264014a0cfb735d4a32be6cbc /sql/opt_subselect.cc
parent92a13148e80c30422ae5460032169cbe1946fa6d (diff)
parentff579bc814551026a3271fac274f560cef3f523f (diff)
downloadmariadb-git-9b1824dcd2564c803e58d02ac63b49ec68bd60d2.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/opt_subselect.cc')
-rw-r--r--sql/opt_subselect.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index b28adae0a44..7b081218dea 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -3741,8 +3741,7 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm= emb_sj_nest->sj_mat_info;
thd= tab->join->thd;
/* First the calls come to the materialization function */
- //List<Item> &item_list= emb_sj_nest->sj_subq_pred->unit->first_select()->item_list;
-
+
DBUG_ASSERT(sjm->is_used);
/*
Set up the table to write to, do as select_union::create_result_table does
@@ -3750,10 +3749,22 @@ bool setup_sj_materialization_part1(JOIN_TAB *sjm_tab)
sjm->sjm_table_param.init();
sjm->sjm_table_param.bit_fields_as_long= TRUE;
SELECT_LEX *subq_select= emb_sj_nest->sj_subq_pred->unit->first_select();
- Ref_ptr_array p_items= subq_select->ref_pointer_array;
- for (uint i= 0; i < subq_select->item_list.elements; i++)
- sjm->sjm_table_cols.push_back(p_items[i], thd->mem_root);
-
+ List_iterator<Item> it(subq_select->item_list);
+ Item *item;
+ while((item= it++))
+ {
+ /*
+ This semi-join replaced the subquery (subq_select) and so on
+ re-executing it will not be prepared. To use the Items from its
+ select list we have to prepare (fix_fields) them
+ */
+ if (!item->fixed && item->fix_fields(thd, it.ref()))
+ DBUG_RETURN(TRUE);
+ item= *(it.ref()); // it can be changed by fix_fields
+ DBUG_ASSERT(!item->name_length || item->name_length == strlen(item->name));
+ sjm->sjm_table_cols.push_back(item, thd->mem_root);
+ }
+
sjm->sjm_table_param.field_count= subq_select->item_list.elements;
sjm->sjm_table_param.force_not_null_cols= TRUE;