summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc47
1 files changed, 20 insertions, 27 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 6444f672176..b0eb22d2e0e 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -734,7 +734,7 @@ int Item_in_subselect::optimize(double *out_rows, double *cost)
}
/* Now with grouping */
- if (join->group_list)
+ if (join->group_list_for_estimates)
{
DBUG_PRINT("info",("Materialized join has grouping, trying to estimate it"));
double output_rows= get_post_group_estimate(join, *out_rows);
@@ -1891,7 +1891,8 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
(ALL && (> || =>)) || (ANY && (< || =<))
for ALL condition is inverted
*/
- item= new (thd->mem_root) Item_sum_max(thd, *select_lex->ref_pointer_array);
+ item= new (thd->mem_root) Item_sum_max(thd,
+ select_lex->ref_pointer_array[0]);
}
else
{
@@ -1899,11 +1900,12 @@ bool Item_allany_subselect::transform_into_max_min(JOIN *join)
(ALL && (< || =<)) || (ANY && (> || =>))
for ALL condition is inverted
*/
- item= new (thd->mem_root) Item_sum_min(thd, *select_lex->ref_pointer_array);
+ item= new (thd->mem_root) Item_sum_min(thd,
+ select_lex->ref_pointer_array[0]);
}
if (upper_item)
upper_item->set_sum_test(item);
- thd->change_item_tree(select_lex->ref_pointer_array, item);
+ thd->change_item_tree(&select_lex->ref_pointer_array[0], item);
{
List_iterator<Item> it(select_lex->item_list);
it++;
@@ -2049,8 +2051,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
thd,
&select_lex->context,
this,
- select_lex->
- ref_pointer_array,
+ &select_lex->
+ ref_pointer_array[0],
(char *)"<ref>",
this->full_name()));
if (!abort_on_null && left_expr->maybe_null)
@@ -2125,7 +2127,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
new (thd->mem_root) Item_ref_null_helper(thd,
&select_lex->context,
this,
- select_lex->ref_pointer_array,
+ &select_lex->ref_pointer_array[0],
(char *)"<no matter>",
(char *)"<result>"));
if (!abort_on_null && left_expr->maybe_null)
@@ -2312,7 +2314,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(char *)in_left_expr_name),
new (thd->mem_root)
Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array + i,
+ &select_lex->ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
Item *item_isnull=
@@ -2320,7 +2322,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_func_isnull(thd,
new (thd->mem_root)
Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array+i,
+ &select_lex->ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
Item *col_item= new (thd->mem_root)
@@ -2338,8 +2340,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_is_not_null_test(thd, this,
new (thd->mem_root)
Item_ref(thd, &select_lex->context,
- select_lex->
- ref_pointer_array + i,
+ &select_lex->
+ ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
if (!abort_on_null && left_expr->element_index(i)->maybe_null)
@@ -2377,8 +2379,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(char *)in_left_expr_name),
new (thd->mem_root)
Item_direct_ref(thd, &select_lex->context,
- select_lex->
- ref_pointer_array+i,
+ &select_lex->
+ ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null)
@@ -2388,7 +2390,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_is_not_null_test(thd, this,
new (thd->mem_root)
Item_ref(thd, &select_lex->context,
- select_lex->ref_pointer_array + i,
+ &select_lex->ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
@@ -2397,8 +2399,8 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_func_isnull(thd,
new (thd->mem_root)
Item_direct_ref(thd, &select_lex->context,
- select_lex->
- ref_pointer_array+i,
+ &select_lex->
+ ref_pointer_array[i],
(char *)"<no matter>",
(char *)"<list ref>"));
item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
@@ -3528,8 +3530,7 @@ int subselect_single_select_engine::prepare()
prepared= 1;
SELECT_LEX *save_select= thd->lex->current_select;
thd->lex->current_select= select_lex;
- if (join->prepare(&select_lex->ref_pointer_array,
- select_lex->table_list.first,
+ if (join->prepare(select_lex->table_list.first,
select_lex->with_wild,
select_lex->where,
select_lex->order_list.elements +
@@ -3678,14 +3679,6 @@ int subselect_single_select_engine::exec()
*/
select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
- /*
- Force join->join_tmp creation, because this subquery will be replaced
- by a simple select from the materialization temp table by optimize()
- called by EXPLAIN and we need to preserve the initial query structure
- so we can display it.
- */
- if (join->need_tmp && join->init_save_join_tab())
- DBUG_RETURN(1); /* purecov: inspected */
}
}
if (item->engine_changed(this))
@@ -5226,7 +5219,7 @@ double get_post_group_estimate(JOIN* join, double join_op_rows)
table_map tables_in_group_list= table_map(0);
/* Find out which tables are used in GROUP BY list */
- for (ORDER *order= join->group_list; order; order= order->next)
+ for (ORDER *order= join->group_list_for_estimates; order; order= order->next)
{
Item *item= order->item[0];
table_map item_used_tables= item->used_tables();