mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Fixed bug mdev-10923.
The code for st_select_lex::find_table_def_in_with_clauses() did not take into account the fact that the specs for mergeable CTEs were cloned and were not processed by the function With_element::check_dependencies_in_spec().
This commit is contained in:
parent
903f34c7a9
commit
061d28207d
3 changed files with 74 additions and 4 deletions
|
@ -895,3 +895,35 @@ SELECT * FROM t1, t2 WHERE a2 = i1 and b2 >= i1 AND i1 IN ( SELECT i3 FROM t3 )
|
|||
;
|
||||
i1 a2 b2
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-10923: mergeable CTE used twice in the query
|
||||
#
|
||||
create table employees (
|
||||
name varchar(32),
|
||||
dept varchar(32),
|
||||
country varchar(8)
|
||||
);
|
||||
insert into employees
|
||||
values
|
||||
('Sergei Golubchik', 'Development', 'DE'),
|
||||
('Claudio Nanni', 'Support', 'ES'),
|
||||
('Sergei Petrunia', 'Development', 'RU');
|
||||
with eng as
|
||||
(
|
||||
select * from employees
|
||||
where dept in ('Development','Support')
|
||||
),
|
||||
eu_eng as
|
||||
(
|
||||
select * from eng where country IN ('DE','ES','RU')
|
||||
)
|
||||
select * from eu_eng T1
|
||||
where
|
||||
not exists (select 1 from eu_eng T2
|
||||
where T2.country=T1.country
|
||||
and T2.name <> T1.name);
|
||||
name dept country
|
||||
Sergei Golubchik Development DE
|
||||
Claudio Nanni Support ES
|
||||
Sergei Petrunia Development RU
|
||||
drop table employees;
|
||||
|
|
|
@ -576,3 +576,36 @@ UNION
|
|||
SELECT * FROM t1, t2 WHERE a2 = i1 and b2 >= i1 AND i1 IN ( SELECT i3 FROM t3 )
|
||||
;
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10923: mergeable CTE used twice in the query
|
||||
--echo #
|
||||
|
||||
create table employees (
|
||||
name varchar(32),
|
||||
dept varchar(32),
|
||||
country varchar(8)
|
||||
);
|
||||
|
||||
insert into employees
|
||||
values
|
||||
('Sergei Golubchik', 'Development', 'DE'),
|
||||
('Claudio Nanni', 'Support', 'ES'),
|
||||
('Sergei Petrunia', 'Development', 'RU');
|
||||
|
||||
with eng as
|
||||
(
|
||||
select * from employees
|
||||
where dept in ('Development','Support')
|
||||
),
|
||||
eu_eng as
|
||||
(
|
||||
select * from eng where country IN ('DE','ES','RU')
|
||||
)
|
||||
select * from eu_eng T1
|
||||
where
|
||||
not exists (select 1 from eu_eng T2
|
||||
where T2.country=T1.country
|
||||
and T2.name <> T1.name);
|
||||
|
||||
drop table employees;
|
||||
|
|
|
@ -928,13 +928,18 @@ With_element *st_select_lex::find_table_def_in_with_clauses(TABLE_LIST *table)
|
|||
/*
|
||||
If sl->master_unit() is the spec of a with element then the search for
|
||||
a definition was already done by With_element::check_dependencies_in_spec
|
||||
and it was unsuccesful.
|
||||
and it was unsuccesful. Yet for units cloned from the spec it has not
|
||||
been done yet.
|
||||
*/
|
||||
if (with_elem)
|
||||
if (with_elem && sl->master_unit() == with_elem->spec)
|
||||
break;
|
||||
With_clause *with_clause=sl->get_with_clause();
|
||||
if (with_clause && (found= with_clause->find_table_def(table,NULL)))
|
||||
break;
|
||||
if (with_clause)
|
||||
{
|
||||
With_element *barrier= with_clause->with_recursive ? NULL : with_elem;
|
||||
if ((found= with_clause->find_table_def(table, barrier)))
|
||||
break;
|
||||
}
|
||||
master_unit= sl->master_unit();
|
||||
/* Do not look for the table's definition beyond the scope of the view */
|
||||
if (master_unit->is_view)
|
||||
|
|
Loading…
Reference in a new issue