From e59c1cef3bc4016f9fa9d7a0f6935463b7283a58 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 28 Dec 2020 21:20:13 -0800 Subject: Correction of the merge 10.2 into 10.3 for MDEV-23619 (correction for commit 6fed6de93f120b5e311b79892e7865639e9613a4) --- mysql-test/main/cte_recursive.result | 4 ++-- sql/sql_lex.cc | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result index 62354a619c1..21c6b225a89 100644 --- a/mysql-test/main/cte_recursive.result +++ b/mysql-test/main/cte_recursive.result @@ -1301,7 +1301,7 @@ select ancestors.name, ancestors.dob from ancestors; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY ALL NULL NULL NULL NULL 24 4 DERIVED folks ALL NULL NULL NULL NULL 12 Using where -6 RECURSIVE UNION ALL NULL NULL NULL NULL 12 +6 UNION ALL NULL NULL NULL NULL 12 5 RECURSIVE UNION ALL NULL NULL NULL NULL 24 NULL UNION RESULT ALL NULL NULL NULL NULL NULL 3 DERIVED folks ALL NULL NULL NULL NULL 12 Using where @@ -4029,7 +4029,7 @@ id select_type table type possible_keys key key_len ref rows Extra 3 RECURSIVE UNION t1 ALL NULL NULL NULL NULL 4 Using where 3 RECURSIVE UNION ref key0 key0 9 test.t1.c 2 NULL UNION RESULT ALL NULL NULL NULL NULL NULL -4 RECURSIVE UNION ALL NULL NULL NULL NULL 4 +4 UNION ALL NULL NULL NULL NULL 4 with recursive r_cte as ( select * from t1 as s union diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index dc0662e11b8..6116dee6e7e 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4712,14 +4712,14 @@ void st_select_lex::set_explain_type(bool on_the_fly) /* pos_in_table_list=NULL for e.g. post-join aggregation JOIN_TABs. */ - if (!tab->table); - else if (const TABLE_LIST *pos= tab->table->pos_in_table_list) + if (!(tab->table && tab->table->pos_in_table_list)) + continue; + TABLE_LIST *tbl= tab->table->pos_in_table_list; + if (tbl->with && tbl->with->is_recursive && + tbl->is_with_table_recursive_reference()) { - if (pos->with && pos->with->is_recursive) - { - uses_cte= true; - break; - } + uses_cte= true; + break; } } if (uses_cte) -- cgit v1.2.1