Browse Source
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.
pull/3115/head
Yuchen Pei
1 year ago
No known key found for this signature in database
GPG Key ID: 3DD1B35105743563
3 changed files with
57 additions and
0 deletions
sql/item_subselect.cc
storage/spider/mysql-test/spider/bugfix/r/mdev_30408.result
storage/spider/mysql-test/spider/bugfix/t/mdev_30408.test
@ -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 ) ) )
{
@ -0,0 +1,30 @@
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
@ -0,0 +1,26 @@
--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