summaryrefslogtreecommitdiff
path: root/sql/sql_cte.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-05-05 16:12:54 +0400
committerAlexander Barkov <bar@mariadb.org>2017-05-05 16:12:54 +0400
commitac53b49b1be807f588aebd83883ec93b764f5d54 (patch)
treec86cbdb535eefb15e2077a7ac2ffaeff9d76955e /sql/sql_cte.h
parent583b68e89961c35fa95a06c38988f82e33c73f4a (diff)
parentdb0917f68f2681882974afd53935aa8cba29c6b8 (diff)
downloadmariadb-git-ac53b49b1be807f588aebd83883ec93b764f5d54.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'sql/sql_cte.h')
-rw-r--r--sql/sql_cte.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/sql/sql_cte.h b/sql/sql_cte.h
index a87c1b8acbd..85676df9d39 100644
--- a/sql/sql_cte.h
+++ b/sql/sql_cte.h
@@ -46,6 +46,16 @@ private:
/* Dependency map of with elements mutually recursive with this with element */
table_map mutually_recursive;
/*
+ Dependency map built only for the top level references i.e. for those that
+ are encountered in from lists of the selects of the specification unit
+ */
+ table_map top_level_dep_map;
+ /*
+ Points to a recursive reference in subqueries.
+ Used only for specifications without recursive references on the top level.
+ */
+ TABLE_LIST *sq_rec_ref;
+ /*
The next with element from the circular chain of the with elements
mutually recursive with this with element.
(If This element is simply recursive than next_mutually_recursive contains
@@ -119,11 +129,15 @@ public:
*/
select_union_recursive *rec_result;
+ /* List of Item_subselects containing recursive references to this CTE */
+ SQL_I_List<Item_subselect> sq_with_rec_ref;
+
With_element(LEX_CSTRING *name,
List <LEX_CSTRING> list,
st_select_lex_unit *unit)
: next(NULL), base_dep_map(0), derived_dep_map(0),
sq_dep_map(0), work_dep_map(0), mutually_recursive(0),
+ top_level_dep_map(0), sq_rec_ref(NULL),
next_mutually_recursive(NULL), references(0),
query_name(name), column_list(list), spec(unit),
is_recursive(false), with_anchor(false),
@@ -151,6 +165,8 @@ public:
bool check_dependency_on(With_element *with_elem)
{ return base_dep_map & with_elem->get_elem_map(); }
+ TABLE_LIST *find_first_sq_rec_ref_in_select(st_select_lex *sel);
+
bool set_unparsed_spec(THD *thd, char *spec_start, char *spec_end);
st_select_lex_unit *clone_parsed_spec(THD *thd, TABLE_LIST *with_table);
@@ -174,11 +190,16 @@ public:
bool contains_sq_with_recursive_reference()
{ return sq_dep_map & mutually_recursive; }
+ bool no_rec_ref_on_top_level()
+ { return !(top_level_dep_map & mutually_recursive); }
+
table_map get_mutually_recursive() { return mutually_recursive; }
With_element *get_next_mutually_recursive()
{ return next_mutually_recursive; }
+ TABLE_LIST *get_sq_rec_ref() { return sq_rec_ref; }
+
bool is_anchor(st_select_lex *sel);
void move_anchors_ahead();