Commit 3a7f2879 authored by unknown's avatar unknown

Merge the fix of bug lp:825051

parents 264aaf11 625cdb80
...@@ -5842,5 +5842,31 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -5842,5 +5842,31 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
(SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0) (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0)
NULL NULL
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
#
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 SUBQUERY t1 index NULL a 4 NULL 2 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
...@@ -5841,6 +5841,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -5841,6 +5841,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
(SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0) (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0)
NULL NULL
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
#
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 SUBQUERY t1 index NULL a 4 NULL 2 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set optimizer_switch=default; set optimizer_switch=default;
......
...@@ -5837,6 +5837,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -5837,6 +5837,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
(SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0) (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0)
NULL NULL
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
#
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 SUBQUERY t1 index NULL a 4 NULL 2 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;
...@@ -5846,6 +5846,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -5846,6 +5846,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
(SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0) (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0)
NULL NULL
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
#
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 SUBQUERY t1 index NULL a 4 NULL 2 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set optimizer_switch=default; set optimizer_switch=default;
......
...@@ -5837,6 +5837,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -5837,6 +5837,32 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
(SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0) (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0)
NULL NULL
drop tables t1,t2,t3; drop tables t1,t2,t3;
#
# LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
#
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 SUBQUERY t1 index NULL a 4 NULL 2 Using index
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
a
2009-01-01
2009-02-02
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
# return optimizer switch changed in the beginning of this test # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
set @optimizer_switch_for_subselect_test=null; set @optimizer_switch_for_subselect_test=null;
...@@ -4916,5 +4916,21 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0); ...@@ -4916,5 +4916,21 @@ SELECT (SELECT f3a, f3a FROM t3 where f3a > 3) = (0, 0);
drop tables t1,t2,t3; drop tables t1,t2,t3;
--echo #
--echo # LP BUG#825051 Wrong result with date/datetime and subquery with GROUP BY and in_to_exists
--echo #
CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');
set @old_optimizer_switch = @@optimizer_switch;
SET @@optimizer_switch='semijoin=off,materialization=off,in_to_exists=on,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
SET @@optimizer_switch='semijoin=off,materialization=on,in_to_exists=off,subquery_cache=off';
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1);
set @@optimizer_switch=@old_optimizer_switch;
drop table t1;
--echo # return optimizer switch changed in the beginning of this test --echo # return optimizer switch changed in the beginning of this test
set optimizer_switch=@subselect_tmp; set optimizer_switch=@subselect_tmp;
...@@ -3864,7 +3864,7 @@ String* Item_ref_null_helper::val_str(String* s) ...@@ -3864,7 +3864,7 @@ String* Item_ref_null_helper::val_str(String* s)
bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, uint fuzzydate) bool Item_ref_null_helper::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate)); return (owner->was_null|= null_value= (*ref)->get_date_result(ltime, fuzzydate));
} }
......
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