diff options
author | Igor Babaev <igor@askmonty.org> | 2018-05-17 15:47:17 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2018-05-17 15:47:48 -0700 |
commit | d309c2fc885a5d50645ca9b43da2fda09f8b4418 (patch) | |
tree | 3700a16094b80de73e6ecb98fe7e74f4d0fd687f /sql/sql_union.cc | |
parent | ab9d420df37d76a1ff68e6fd2d5bf53a797c4102 (diff) | |
download | mariadb-git-d309c2fc885a5d50645ca9b43da2fda09f8b4418.tar.gz |
MDEV-16212 Memory leak with recursive CTE that uses global ORDER BY
with recursive subquery
There were two problems:
1. The code did not report that usage of global ORDER BY / LIMIT clauses
was not supported yet.
2. The code just reset fake_select_lex of the the unit specifying
a recursive CTE to NULL and that caused memory leaks in some cases.
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 3fe90564000..39e7bcdf051 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -521,7 +521,18 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, with_element->rec_result= new (thd_arg->mem_root) select_union_recursive(thd_arg); union_result= with_element->rec_result; - fake_select_lex= NULL; + if (fake_select_lex) + { + if (fake_select_lex->order_list.first || + fake_select_lex->explicit_limit) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "global ORDER_BY/LIMIT in recursive CTE spec"); + goto err; + } + fake_select_lex->cleanup(); + fake_select_lex= NULL; + } } if (!(tmp_result= union_result)) goto err; /* purecov: inspected */ |