summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2016-09-30 13:10:58 -0700
committerIgor Babaev <igor@askmonty.org>2016-09-30 17:40:42 -0700
commit061d28207d59f37a4010654b7af4df4597140969 (patch)
treec6eb62005d6e816d4f577317655ed998366cc504 /sql/sql_cte.cc
parent903f34c7a99d15ca1b861a7dd4848ebed9891c44 (diff)
downloadmariadb-git-061d28207d59f37a4010654b7af4df4597140969.tar.gz
Fixed bug mdev-10923.
The code for st_select_lex::find_table_def_in_with_clauses() did not take into account the fact that the specs for mergeable CTEs were cloned and were not processed by the function With_element::check_dependencies_in_spec().
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index f203c33780d..7e98a9bd1ff 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -928,13 +928,18 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
/*
If sl->master_unit() is the spec of a with element then the search for
a definition was already done by With_element::check_dependencies_in_spec
- and it was unsuccesful.
+ and it was unsuccesful. Yet for units cloned from the spec it has not
+ been done yet.
*/
- if (with_elem)
+ if (with_elem && sl->master_unit() == with_elem->spec)
break;
With_clause *with_clause=sl->get_with_clause();
- if (with_clause && (found= with_clause->find_table_def(table,NULL)))
- break;
+ if (with_clause)
+ {
+ With_element *barrier= with_clause->with_recursive ? NULL : with_elem;
+ if ((found= with_clause->find_table_def(table, barrier)))
+ break;
+ }
master_unit= sl->master_unit();
/* Do not look for the table's definition beyond the scope of the view */
if (master_unit->is_view)