summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-03-09 15:11:44 -0800
committerIgor Babaev <igor@askmonty.org>2021-03-10 22:16:23 -0800
commit374ec82f0828933a511f82c73a91e018c5353836 (patch)
tree5823f31c65127287153e38b897d9ea407492ba79 /sql/sql_cte.cc
parent90780bb5a949d5e27b39df4adaa1d7b1ad98948e (diff)
downloadmariadb-git-374ec82f0828933a511f82c73a91e018c5353836.tar.gz
MDEV-24597 Explicit column name error in CTE of UNION
This bug manifested itself when executing queries with multiple reference to a CTE specified by a query expression with union and having its column names explicitly declared. In this case the server returned a bogus error message about unknown column name. It happened because while for the first reference to the CTE the names of the columns returned by the CTE specification were properly changed to match the CTE definition for the other references it was not done. This was a consequence of not quite complete code of the function With_element::clone_parsed_spec() that forgot to set the reference to the CTE definition for unit structures representing non-first CTE references. Approved by dmitry.shulga@mariadb.com
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index e07a525f691..3a2301a5730 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -879,6 +879,7 @@ st_select_lex_unit *With_element::clone_parsed_spec(THD *thd,
with_table->next_global= spec_tables;
}
res= &lex->unit;
+ res->with_element= this;
lex->unit.include_down(with_table->select_lex);
lex->unit.set_slave(with_select);