Commit 41021c02 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-9462: Out of memory using explain on 2 empty tables

Fixed adding derived tables items to outer one.
parent ad94790f
This diff is collapsed.
This diff is collapsed.
...@@ -1060,6 +1060,13 @@ private: ...@@ -1060,6 +1060,13 @@ private:
index_clause_map current_index_hint_clause; index_clause_map current_index_hint_clause;
/* a list of USE/FORCE/IGNORE INDEX */ /* a list of USE/FORCE/IGNORE INDEX */
List<Index_hint> *index_hints; List<Index_hint> *index_hints;
public:
inline void add_where_field(st_select_lex *sel)
{
DBUG_ASSERT(this != sel);
select_n_where_fields+= sel->select_n_where_fields;
}
}; };
typedef class st_select_lex SELECT_LEX; typedef class st_select_lex SELECT_LEX;
......
...@@ -1523,8 +1523,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, ...@@ -1523,8 +1523,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
/* Fields in this view can be used in upper select in case of merge. */ /* Fields in this view can be used in upper select in case of merge. */
if (table->select_lex) if (table->select_lex)
table->select_lex->select_n_where_fields+= table->select_lex->add_where_field(&lex->select_lex);
lex->select_lex.select_n_where_fields;
} }
/* /*
This method has a dependency on the proper lock type being set, This method has a dependency on the proper lock type being set,
......
...@@ -9872,15 +9872,6 @@ table_factor: ...@@ -9872,15 +9872,6 @@ table_factor:
sel->add_joined_table($$); sel->add_joined_table($$);
lex->pop_context(); lex->pop_context();
lex->nest_level--; lex->nest_level--;
/*
Fields in derived table can be used in upper select in
case of merge. We do not add HAVING fields because we do
not merge such derived. We do not add union because
also do not merge them
*/
if (!sel->next_select())
$2->select_n_where_fields+=
sel->select_n_where_fields;
} }
/*else if (($3->select_lex && /*else if (($3->select_lex &&
$3->select_lex->master_unit()->is_union() && $3->select_lex->master_unit()->is_union() &&
...@@ -9901,6 +9892,15 @@ table_factor: ...@@ -9901,6 +9892,15 @@ table_factor:
nest_level is the same as in the outer query */ nest_level is the same as in the outer query */
$$= $3; $$= $3;
} }
/*
Fields in derived table can be used in upper select in
case of merge. We do not add HAVING fields because we do
not merge such derived. We do not add union because
also do not merge them
*/
if ($$ && $$->derived &&
!$$->derived->first_select()->next_select())
$$->select_lex->add_where_field($$->derived->first_select());
} }
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment