mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-14346: incorrect result of intersect with ANY/ALL/IN subquery
Reinit internal state of select_unit before using to correctly run it after first time.
This commit is contained in:
@ -689,4 +689,17 @@ View Create View character_set_client collation_connection
|
|||||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (select 4 AS `4`,4 AS `4`) latin1 latin1_swedish_ci
|
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS (select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) union select `__3`.`c` AS `c`,`__3`.`d` AS `d` from ((select `test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2`) intersect (select `test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t3`)) `__3` union (select 4 AS `4`,4 AS `4`) latin1 latin1_swedish_ci
|
||||||
drop view v1;
|
drop view v1;
|
||||||
drop tables t1,t2,t3;
|
drop tables t1,t2,t3;
|
||||||
|
#
|
||||||
|
# MDEV-14346:incorrect result of intersect with ANY/ALL/IN subquery
|
||||||
|
#
|
||||||
|
CREATE TABLE t (i INT);
|
||||||
|
INSERT INTO t VALUES (1),(2);
|
||||||
|
SELECT * FROM t WHERE i != ANY ( SELECT 6 INTERSECT SELECT 3 );
|
||||||
|
i
|
||||||
|
select i from t where
|
||||||
|
exists ((select 6 as r from dual having t.i <> 6)
|
||||||
|
intersect
|
||||||
|
(select 3 from dual having t.i <> 3));
|
||||||
|
i
|
||||||
|
drop table t;
|
||||||
# End of 10.3 tests
|
# End of 10.3 tests
|
||||||
|
@ -190,4 +190,19 @@ show create view v1;
|
|||||||
drop view v1;
|
drop view v1;
|
||||||
drop tables t1,t2,t3;
|
drop tables t1,t2,t3;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-14346:incorrect result of intersect with ANY/ALL/IN subquery
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t (i INT);
|
||||||
|
INSERT INTO t VALUES (1),(2);
|
||||||
|
SELECT * FROM t WHERE i != ANY ( SELECT 6 INTERSECT SELECT 3 );
|
||||||
|
|
||||||
|
select i from t where
|
||||||
|
exists ((select 6 as r from dual having t.i <> 6)
|
||||||
|
intersect
|
||||||
|
(select 3 from dual having t.i <> 3));
|
||||||
|
|
||||||
|
drop table t;
|
||||||
|
|
||||||
|
|
||||||
--echo # End of 10.3 tests
|
--echo # End of 10.3 tests
|
||||||
|
@ -5103,10 +5103,11 @@ public:
|
|||||||
|
|
||||||
select_unit(THD *thd_arg):
|
select_unit(THD *thd_arg):
|
||||||
select_result_interceptor(thd_arg),
|
select_result_interceptor(thd_arg),
|
||||||
curr_step(0), prev_step(0), curr_sel(UINT_MAX),
|
intersect_mark(0), table(0)
|
||||||
step(UNION_TYPE), intersect_mark(0), write_err(0), table(0),
|
{
|
||||||
records(0)
|
init();
|
||||||
{ tmp_table_param.init(); }
|
tmp_table_param.init();
|
||||||
|
}
|
||||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||||
/**
|
/**
|
||||||
Do prepare() and prepare2() if they have been postponed until
|
Do prepare() and prepare2() if they have been postponed until
|
||||||
@ -5130,6 +5131,14 @@ public:
|
|||||||
bool keep_row_order,
|
bool keep_row_order,
|
||||||
uint hidden);
|
uint hidden);
|
||||||
TMP_TABLE_PARAM *get_tmp_table_param() { return &tmp_table_param; }
|
TMP_TABLE_PARAM *get_tmp_table_param() { return &tmp_table_param; }
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
curr_step= prev_step= 0;
|
||||||
|
curr_sel= UINT_MAX;
|
||||||
|
step= UNION_TYPE;
|
||||||
|
write_err= 0;
|
||||||
|
records= 0;
|
||||||
|
}
|
||||||
void change_select();
|
void change_select();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1384,6 +1384,9 @@ bool st_select_lex_unit::exec()
|
|||||||
if (saved_error)
|
if (saved_error)
|
||||||
DBUG_RETURN(saved_error);
|
DBUG_RETURN(saved_error);
|
||||||
|
|
||||||
|
if (union_result)
|
||||||
|
union_result->init();
|
||||||
|
|
||||||
if (uncacheable || !item || !item->assigned() || describe)
|
if (uncacheable || !item || !item->assigned() || describe)
|
||||||
{
|
{
|
||||||
if (!fake_select_lex && !(with_element && with_element->is_recursive))
|
if (!fake_select_lex && !(with_element && with_element->is_recursive))
|
||||||
|
Reference in New Issue
Block a user