summaryrefslogtreecommitdiff
path: root/sql/sql_cte.h
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-10-01 23:07:26 +0200
committerSergei Golubchik <serg@mariadb.org>2022-10-01 23:07:26 +0200
commitd4f6d2f08f228778fd7744554d8b12be05b6a114 (patch)
tree2ccc39d16d3a5be27c54e03a81d2d3f75cfb9266 /sql/sql_cte.h
parent3744b8ae3171fd423f89c64a83d3afc7e3722856 (diff)
parentdd8833bff0af1b75e007e3db1d18debfb7c4a096 (diff)
downloadmariadb-git-d4f6d2f08f228778fd7744554d8b12be05b6a114.tar.gz
Merge branch '10.3' into 10.4
Diffstat (limited to 'sql/sql_cte.h')
-rw-r--r--sql/sql_cte.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/sql_cte.h b/sql/sql_cte.h
index c0624c5e9e1..39648d731c7 100644
--- a/sql/sql_cte.h
+++ b/sql/sql_cte.h
@@ -390,10 +390,24 @@ public:
bool add_with_element(With_element *elem);
/* Add this with clause to the list of with clauses used in the statement */
- void add_to_list(With_clause ** &last_next)
+ void add_to_list(With_clause **ptr, With_clause ** &last_next)
{
- *last_next= this;
- last_next= &this->next_with_clause;
+ if (embedding_with_clause)
+ {
+ /*
+ An embedded with clause is always placed before the embedding one
+ in the list of with clauses used in the query.
+ */
+ while (*ptr != embedding_with_clause)
+ ptr= &(*ptr)->next_with_clause;
+ *ptr= this;
+ next_with_clause= embedding_with_clause;
+ }
+ else
+ {
+ *last_next= this;
+ last_next= &this->next_with_clause;
+ }
}
st_select_lex_unit *get_owner() { return owner; }