diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-02-09 12:48:23 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-02-09 12:48:23 +0200 |
commit | 5559905d4186ce62c9df49d41d0f05c1189fd753 (patch) | |
tree | cd63124d895d16e37f222a14b6980f649a4fe9c6 /sql/sql_cte.cc | |
parent | c567369ad722bb32aaf790be25450dc908542cdb (diff) | |
parent | 7c1bd8fa04962bcdf9b9e3ea2d51bdb6d0fb88e9 (diff) | |
download | mariadb-git-5559905d4186ce62c9df49d41d0f05c1189fd753.tar.gz |
Merge 10.2 into bb-10.2-ext
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r-- | sql/sql_cte.cc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 2fdd493b45d..23a3eba1615 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1000,6 +1000,10 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) and it was unsuccesful. Yet for units cloned from the spec it has not been done yet. */ + With_clause *attached_with_clause= sl->get_with_clause(); + if (attached_with_clause && + (found= attached_with_clause->find_table_def(table, NULL))) + break; master_unit= sl->master_unit(); outer_sl= master_unit->outer_select(); With_element *with_elem= sl->get_with_element(); @@ -1013,13 +1017,6 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) if (outer_sl && !outer_sl->get_with_element()) break; } - else - { - With_clause *attached_with_clause= sl->get_with_clause(); - if (attached_with_clause && - (found= attached_with_clause->find_table_def(table, NULL))) - break; - } /* Do not look for the table's definition beyond the scope of the view */ if (master_unit->is_view) break; @@ -1061,7 +1058,7 @@ bool TABLE_LIST::set_as_with_table(THD *thd, With_element *with_elem) if (!with_elem->is_referenced() || with_elem->is_recursive) { derived= with_elem->spec; - if (derived->get_master() != select_lex && + if (derived != select_lex->master_unit() && !is_with_table_recursive_reference()) { derived->move_as_slave(select_lex); @@ -1071,7 +1068,6 @@ bool TABLE_LIST::set_as_with_table(THD *thd, With_element *with_elem) { if(!(derived= with_elem->clone_parsed_spec(thd, this))) return true; - derived->with_element= with_elem; } derived->first_select()->linkage= DERIVED_TABLE_TYPE; with_elem->inc_references(); |