From e34d3184fd02967616bb83904aa3c21977ce6205 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 16 Apr 2018 10:31:30 -0700 Subject: MDEV-15556 MariaDB crash with big_tables=1 and CTE This bug manifested itself when the optimizer chose an execution plan with an access of the recursive CTE in a recursive query by key and ARIA/MYISAM temporary tables were used to store recursive tables. The problem appeared due to passing an incorrect parameter to the call of instantiate_tmp_table() in the function With_element::instantiate_tmp_tables(). --- sql/sql_cte.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_cte.cc') diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index dd46295d799..6bc833b46a7 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1401,7 +1401,7 @@ bool With_element::instantiate_tmp_tables() { if (!rec_table->is_created() && instantiate_tmp_table(rec_table, - rec_result->tmp_table_param.keyinfo, + rec_table->s->key_info, rec_result->tmp_table_param.start_recinfo, &rec_result->tmp_table_param.recinfo, 0)) -- cgit v1.2.1 From 1d98333ad986d89215f903798a1787ab20308c6b Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 17 Apr 2018 10:35:55 -0700 Subject: MDEV-15894 Error, while using aggregated functions/window functions in anchor part Usage of aggregate/window functions in non-recursive parts of recursive CTEs is allowed. Error messages complaining about this were reported by mistake. --- sql/sql_cte.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_cte.cc') diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index 6bc833b46a7..cd2516c2beb 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -1173,7 +1173,7 @@ bool st_select_lex::check_unrestricted_recursive(bool only_standard_compliant) /* Check conditions 3-4 for restricted specification*/ - if (with_sum_func || + if ((with_sum_func && !with_elem->is_anchor(this)) || (with_elem->contains_sq_with_recursive_reference())) with_elem->get_owner()->add_unrestricted( with_elem->get_mutually_recursive()); -- cgit v1.2.1