Commit 792efd59 authored by unknown's avatar unknown

MDEV-521 fix.

After pullout item during single row subselect transformation it should be fixed properly.
parent 0bc89929
......@@ -6163,5 +6163,20 @@ a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# MDEV-521 single value subselect transformation problem
#
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
DROP TABLE t1;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
......@@ -6162,6 +6162,21 @@ a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# MDEV-521 single value subselect transformation problem
#
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
DROP TABLE t1;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
set optimizer_switch=default;
......
......@@ -6158,6 +6158,21 @@ a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# MDEV-521 single value subselect transformation problem
#
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
DROP TABLE t1;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null;
......@@ -6169,6 +6169,21 @@ a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# MDEV-521 single value subselect transformation problem
#
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
DROP TABLE t1;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
set optimizer_switch=default;
......
......@@ -6158,6 +6158,21 @@ a ( 3, 3 ) NOT IN ( SELECT NULL, NULL )
3 NULL
set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
#
# MDEV-521 single value subselect transformation problem
#
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
f1
u1
u2
DROP TABLE t1;
# return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null;
......
......@@ -5229,5 +5229,18 @@ set optimizer_switch=@mdev367_optimizer_switch;
DROP TABLE t1;
--echo #
--echo # MDEV-521 single value subselect transformation problem
--echo #
CREATE TABLE t1 (f1 char(2), PRIMARY KEY (f1)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('u1'),('u2');
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
FLUSH TABLES;
SELECT a.* FROM t1 a WHERE ( SELECT EXISTS ( SELECT 1 FROM t1 b WHERE b.f1 = a.f1 ) );
# Cleanup
DROP TABLE t1;
--echo # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp;
......@@ -1007,11 +1007,9 @@ Item_singlerow_subselect::select_transformer(JOIN *join)
}
substitution= select_lex->item_list.head();
/*
as far as we moved content to upper level, field which depend of
'upper' select is not really dependent => we remove this dependence
as far as we moved content to upper level we have to fix dependences & Co
*/
substitution->walk(&Item::remove_dependence_processor, 0,
(uchar *) select_lex->outer_select());
substitution->fix_after_pullout(select_lex->outer_select(), &substitution);
}
DBUG_RETURN(false);
}
......
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