diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-09-26 20:49:51 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-09-28 16:37:06 +0200 |
commit | 57e0da50bbef8164635317785b67dd468a908327 (patch) | |
tree | 89d1ed179afce8b040c8f2dfcfe179042ff27b2e /sql/sql_union.cc | |
parent | 7aba6f8f8853acd18d471793f8b72aa1412b8151 (diff) | |
parent | dcbd51cee628d8d8fec9ff5476a6afc855b007aa (diff) | |
download | mariadb-git-57e0da50bbef8164635317785b67dd468a908327.tar.gz |
Merge branch '10.2' into 10.3
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 c8bf9bda57b..6368ed8afd8 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; |