diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-05 08:09:49 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-05 08:09:49 +0300 |
commit | 444c380ceb26895748ce50c50be3f839393ebfd7 (patch) | |
tree | 65b1fbf3b7caec3de48c1f76de4614a2d9793a8d /sql/sql_union.cc | |
parent | 55dd0776566000c5ea12e177df0c784b500ab7c1 (diff) | |
parent | 941ca92a2ca3990020b23bcc92e7ca98dcc8f814 (diff) | |
download | mariadb-git-444c380ceb26895748ce50c50be3f839393ebfd7.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 29ea427842f..1910ad0f83e 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1728,6 +1728,7 @@ bool st_select_lex_unit::exec_recursive() } } thd->lex->current_select= sl; + set_limit(sl); if (sl->tvc) sl->tvc->exec(sl); else @@ -1796,6 +1797,37 @@ bool st_select_lex_unit::cleanup() { DBUG_RETURN(FALSE); } + /* + When processing a PS/SP or an EXPLAIN command cleanup of a unit can + be performed immediately when the unit is reached in the cleanup + traversal initiated by the cleanup of the main unit. + */ + if (!thd->stmt_arena->is_stmt_prepare() && !thd->lex->describe && + with_element && with_element->is_recursive && union_result) + { + select_union_recursive *result= with_element->rec_result; + if (++result->cleanup_count == with_element->rec_outer_references) + { + /* + Perform cleanup for with_element and for all with elements + mutually recursive with it. + */ + cleaned= 1; + with_element->get_next_mutually_recursive()->spec->cleanup(); + } + else + { + /* + Just increment by 1 cleanup_count for with_element and + for all with elements mutually recursive with it. + */ + With_element *with_elem= with_element; + while ((with_elem= with_elem->get_next_mutually_recursive()) != + with_element) + with_elem->rec_result->cleanup_count++; + DBUG_RETURN(FALSE); + } + } cleaned= 1; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) @@ -1826,7 +1858,7 @@ bool st_select_lex_unit::cleanup() if (with_element && with_element->is_recursive) { - if (union_result ) + if (union_result) { ((select_union_recursive *) union_result)->cleanup(); delete union_result; |