summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorGalina Shalygina <galashalygina@gmail.com>2016-05-08 23:04:41 +0300
committerGalina Shalygina <galashalygina@gmail.com>2016-05-08 23:04:41 +0300
commitbe1d06c8a5f843e775374e5ec148aaee56970bdc (patch)
treebd7a95e771ca3b405583dccab8b468dd6fb4509f /sql/sql_lex.cc
parente09b1f2a226bf2763b211f74908a6486b83ebed1 (diff)
downloadmariadb-git-be1d06c8a5f843e775374e5ec148aaee56970bdc.tar.gz
Merge branch '10.2' into 10.2-mdev9864
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 65257c9b2ce..de345b4dd1c 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -748,6 +748,14 @@ void lex_start(THD *thd)
lex->stmt_var_list.empty();
lex->proc_list.elements=0;
+ lex->save_group_list.empty();
+ lex->save_order_list.empty();
+ lex->win_ref= NULL;
+ lex->win_frame= NULL;
+ lex->frame_top_bound= NULL;
+ lex->frame_bottom_bound= NULL;
+ lex->win_spec= NULL;
+
lex->is_lex_started= TRUE;
DBUG_VOID_RETURN;
}
@@ -2070,6 +2078,7 @@ void st_select_lex_unit::init_query()
found_rows_for_union= 0;
insert_table_with_stored_vcol= 0;
derived= 0;
+ is_view= false;
with_clause= 0;
with_element= 0;
columns_are_renamed= false;
@@ -2103,8 +2112,7 @@ void st_select_lex::init_query()
parent_lex->push_context(&context, parent_lex->thd->mem_root);
cond_count= between_count= with_wild= 0;
max_equal_elems= 0;
- ref_pointer_array= 0;
- ref_pointer_array_size= 0;
+ ref_pointer_array.reset();
select_n_where_fields= 0;
select_n_reserved= 0;
select_n_having_items= 0;
@@ -2122,8 +2130,11 @@ void st_select_lex::init_query()
prep_leaf_list_state= UNINIT;
have_merged_subqueries= FALSE;
bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used));
+ select_list_tables= 0;
m_non_agg_field_used= false;
m_agg_func_used= false;
+ window_specs.empty();
+ window_funcs.empty();
}
void st_select_lex::init_select()
@@ -2650,7 +2661,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
select_n_having_items +
select_n_where_fields +
order_group_num) * 5;
- if (ref_pointer_array != NULL)
+ if (!ref_pointer_array.is_null())
{
/*
We need to take 'n_sum_items' into account when allocating the array,
@@ -2659,17 +2670,24 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
In the usual case we can reuse the array from the prepare phase.
If we need a bigger array, we must allocate a new one.
*/
- if (ref_pointer_array_size >= n_elems)
- {
- DBUG_PRINT("info", ("reusing old ref_array"));
+ if (ref_pointer_array.size() == n_elems)
return false;
- }
- }
- ref_pointer_array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));
- if (ref_pointer_array != NULL)
- ref_pointer_array_size= n_elems;
- return ref_pointer_array == NULL;
+ /*
+ We need to take 'n_sum_items' into account when allocating the array,
+ and this may actually increase during the optimization phase due to
+ MIN/MAX rewrite in Item_in_subselect::single_value_transformer.
+ In the usual case we can reuse the array from the prepare phase.
+ If we need a bigger array, we must allocate a new one.
+ */
+ if (ref_pointer_array.size() == n_elems)
+ return false;
+ }
+ Item **array= static_cast<Item**>(arena->alloc(sizeof(Item*) * n_elems));
+ if (array != NULL)
+ ref_pointer_array= Ref_ptr_array(array, n_elems);
+
+ return array == NULL;
}
@@ -2734,8 +2752,8 @@ void st_select_lex::print_order(String *str,
else
(*order->item)->print(str, query_type);
}
- if (!order->asc)
- str->append(STRING_WITH_LEN(" desc"));
+ if (order->direction == ORDER::ORDER_DESC)
+ str->append(STRING_WITH_LEN(" desc"));
if (order->next)
str->append(',');
}
@@ -4177,9 +4195,11 @@ void SELECT_LEX::update_used_tables()
Item *item;
List_iterator_fast<Item> it(join->fields_list);
+ select_list_tables= 0;
while ((item= it++))
{
item->update_used_tables();
+ select_list_tables|= item->used_tables();
}
Item_outer_ref *ref;
List_iterator_fast<Item_outer_ref> ref_it(inner_refs_list);
@@ -4229,6 +4249,8 @@ void st_select_lex::update_correlated_cache()
if (join->conds)
is_correlated|= MY_TEST(join->conds->used_tables() & OUTER_REF_TABLE_BIT);
+ is_correlated|= join->having_is_correlated;
+
if (join->having)
is_correlated|= MY_TEST(join->having->used_tables() & OUTER_REF_TABLE_BIT);