diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-05-22 11:47:09 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-05-22 11:47:09 +0200 |
commit | 4ec8598c1dcb63499bce998142b8e5b8b09b2d30 (patch) | |
tree | 23010dcb3489b54b4bc9b26481a4a16a4378914a /sql/sql_cte.cc | |
parent | fe3bf136b6cf83aac5a6e21d3db1c4e821612017 (diff) | |
parent | afe5a51c2df95aa282e4459afeb7f037563def92 (diff) | |
download | mariadb-git-4ec8598c1dcb63499bce998142b8e5b8b09b2d30.tar.gz |
Merge branch 'github/10.2' into 10.3
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r-- | sql/sql_cte.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index c92fb3d97ba..97bbf8f73bd 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -682,7 +682,6 @@ void With_element::move_anchors_ahead() { st_select_lex *next_sl; st_select_lex *new_pos= spec->first_select(); - st_select_lex *UNINIT_VAR(last_sl); new_pos->linkage= UNION_TYPE; for (st_select_lex *sl= new_pos; sl; sl= next_sl) { @@ -690,6 +689,14 @@ void With_element::move_anchors_ahead() if (is_anchor(sl)) { sl->move_node(new_pos); + if (new_pos == spec->first_select()) + { + enum sub_select_type type= new_pos->linkage; + new_pos->linkage= sl->linkage; + sl->linkage= type; + new_pos->with_all_modifier= sl->with_all_modifier; + sl->with_all_modifier= false; + } new_pos= sl->next_select(); } else if (!sq_rec_ref && no_rec_ref_on_top_level()) @@ -697,10 +704,7 @@ void With_element::move_anchors_ahead() sq_rec_ref= find_first_sq_rec_ref_in_select(sl); DBUG_ASSERT(sq_rec_ref != NULL); } - last_sl= sl; } - if (spec->union_distinct) - spec->union_distinct= last_sl; first_recursive= new_pos; } @@ -829,8 +833,9 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd, if (parser_state.init(thd, (char*) unparsed_spec.str, (unsigned int)unparsed_spec.length)) goto err; lex_start(thd); + lex->stmt_lex= old_lex; with_select= &lex->select_lex; - with_select->select_number= ++thd->stmt_lex->current_select_number; + with_select->select_number= ++thd->lex->stmt_lex->current_select_number; parse_status= parse_sql(thd, &parser_state, 0); if (parse_status) goto err; |