diff options
author | Alexander Barkov <bar@mariadb.org> | 2017-10-30 20:47:39 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2017-10-30 20:47:39 +0400 |
commit | 835cbbcc7b797188a89671019f2b2844e1a14e0c (patch) | |
tree | 010dd112f16b88bb655c32abb6b93987fe5c6c99 /sql/sql_cte.cc | |
parent | fe8cf8fdf1c4c0a9ec60690a8d2738fd255c8dd5 (diff) | |
parent | 003cb2f42477772ae43228c0bc0f8492246b9340 (diff) | |
download | mariadb-git-835cbbcc7b797188a89671019f2b2844e1a14e0c.tar.gz |
Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3
TODO: enable MDEV-13049 optimization for 10.3
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r-- | sql/sql_cte.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 2047c7c8762..ad37ef36e2c 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1007,7 +1007,7 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table) been done yet. */ if (with_elem && sl->master_unit() == with_elem->spec) - break; + break; With_clause *with_clause=sl->get_with_clause(); if (with_clause) { @@ -1055,13 +1055,21 @@ bool TABLE_LIST::set_as_with_table(THD *thd, With_element *with_elem) } with= with_elem; if (!with_elem->is_referenced() || with_elem->is_recursive) + { derived= with_elem->spec; + if (derived->get_master() != select_lex && + !is_with_table_recursive_reference()) + { + derived->move_as_slave(select_lex); + } + } else { 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(); return false; } |