summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2020-12-04 14:20:52 -0800
committerIgor Babaev <igor@askmonty.org>2020-12-07 09:26:40 -0800
commit2db6eb142956cd1744cf5c452bca66b20067d73e (patch)
tree04f922d78a9541f8ebd61ccde024a0dc972bf293 /sql
parentf924a3bd6cd70c140f00d162ad18da003cc87a89 (diff)
downloadmariadb-git-2db6eb142956cd1744cf5c452bca66b20067d73e.tar.gz
MDEV-22781 CREATE VIEW containing WITH clause Signal 11
For table references to CTEs the field TABLE_LIST::db must be set to an empty string as it's done for table references to derived tables in order CTEs to be processed similar to how derived tables are processed. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_cte.cc1
-rw-r--r--sql/sql_view.cc2
2 files changed, 3 insertions, 0 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index fe8e0de71b4..a8bccf0c1dd 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -227,6 +227,7 @@ With_element *With_clause::find_table_def(TABLE_LIST *table,
!table->is_fqtn)
{
table->set_derived();
+ table->db= empty_c_string;
return with_elem;
}
}
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 8bfe6896ea2..0701c5233ac 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -291,6 +291,8 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view,
{
for (tbl= sl->get_table_list(); tbl; tbl= tbl->next_local)
{
+ if (!tbl->with && tbl->select_lex)
+ tbl->with= tbl->select_lex->find_table_def_in_with_clauses(tbl);
/*
Ensure that we have some privileges on this table, more strict check
will be done on column level after preparation,