Commit 247632e6 authored by Igor Babaev's avatar Igor Babaev

Fixed bug mdev-10344.

The patch for bug mdev-9937 actually did not fix the problem
of name resolution for tables used in views referred in queries
with WITH clauses. This fix corrects the patch.
parent f982d107
...@@ -780,3 +780,26 @@ a ...@@ -780,3 +780,26 @@ a
2 2
3 3
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
#
# Bug mdev-10344: the WITH clause of the query refers to a view that uses
# a base table with the same name as a CTE table from the clause
#
create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table one_k(a int primary key);
insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
create view v1 as select * from ten;
select * from v1;
a
0
1
2
3
4
5
6
7
8
9
drop view v1;
drop table ten, one_k;
...@@ -471,3 +471,21 @@ SELECT * FROM (WITH a AS (SELECT * FROM t1) SELECT * FROM t2 NATURAL JOIN t3) AS ...@@ -471,3 +471,21 @@ SELECT * FROM (WITH a AS (SELECT * FROM t1) SELECT * FROM t2 NATURAL JOIN t3) AS
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
--echo #
--echo # Bug mdev-10344: the WITH clause of the query refers to a view that uses
--echo # a base table with the same name as a CTE table from the clause
--echo #
create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table one_k(a int primary key);
insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
create view v1 as select * from ten;
select * from v1;
drop view v1;
drop table ten, one_k;
...@@ -1622,7 +1622,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, ...@@ -1622,7 +1622,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
sl->context.error_processor_data= (void *)table; sl->context.error_processor_data= (void *)table;
} }
table->select_lex->master_unit()->is_view= true; view_select->master_unit()->is_view= true;
/* /*
check MERGE algorithm ability check MERGE algorithm ability
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment