Commit 03a35037 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-30408 Reset explicit_limit in exists2in

Item_exists_subselect::fix_length_and_dec() sets explicit_limit to 1.
In the exists2in transformation it resets select_limit to NULL. For
consistency we should reset explicity_limit too.

This fixes a bug where spider table returns wrong results for queries
that gets through exists2in transformation when semijoin is off.
parent 8416fd32
......@@ -3186,6 +3186,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
set_exists_transformed();
first_select->select_limit= NULL;
first_select->explicit_limit= FALSE;
if (!(in_subs= new (thd->mem_root) Item_in_subselect(thd, left_exp,
first_select)))
{
......
for master_1
for child2
for child3
set @@optimizer_switch="semijoin=off";
set spider_same_server_link= 1;
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, b int);
insert into t2 select a,a from ten;
create table t1 (a int, b int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
select a.a, a.b from t1 a where exists (select * from t1 b where b.b = a.b);
a b
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
drop table ten, t1, t2;
drop server srv;
for master_1
for child2
for child3
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
set @@optimizer_switch="semijoin=off";
set spider_same_server_link= 1;
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (a int, b int);
insert into t2 select a,a from ten;
create table t1 (a int, b int) ENGINE=Spider
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
select a.a, a.b from t1 a where exists (select * from t1 b where b.b = a.b);
drop table ten, t1, t2;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
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