Commit e3e2358f authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #751350.

The third parameter in the call of make_cond_for_table() that
built the pushed condition containing only outer references
was incorrect. This condition appeared for the first time in
the patch fixing bug 729039.
  
parent aaf9fb0d
......@@ -5068,3 +5068,22 @@ pk i
12 5
15 0
DROP table t1,t2;
#
# Bug#751350: crash with pushed condition for outer references when
# there should be none of such conditions
#
CREATE TABLE t1 (a int, b int) ;
INSERT INTO t1 VALUES (0,0),(0,0);
EXPLAIN
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
b
0
DROP TABLE t1;
......@@ -5070,6 +5070,25 @@ pk i
12 5
15 0
DROP table t1,t2;
#
# Bug#751350: crash with pushed condition for outer references when
# there should be none of such conditions
#
CREATE TABLE t1 (a int, b int) ;
INSERT INTO t1 VALUES (0,0),(0,0);
EXPLAIN
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
b
0
DROP TABLE t1;
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
@@optimizer_switch like '%materialization=on%'
......
......@@ -5067,4 +5067,23 @@ pk i
12 5
15 0
DROP table t1,t2;
#
# Bug#751350: crash with pushed condition for outer references when
# there should be none of such conditions
#
CREATE TABLE t1 (a int, b int) ;
INSERT INTO t1 VALUES (0,0),(0,0);
EXPLAIN
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
b
0
DROP TABLE t1;
set optimizer_switch=default;
......@@ -5067,4 +5067,23 @@ pk i
12 5
15 0
DROP table t1,t2;
#
# Bug#751350: crash with pushed condition for outer references when
# there should be none of such conditions
#
CREATE TABLE t1 (a int, b int) ;
INSERT INTO t1 VALUES (0,0),(0,0);
EXPLAIN
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
b
0
DROP TABLE t1;
set optimizer_switch=default;
......@@ -4333,3 +4333,22 @@ EXPLAIN SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
SELECT * FROM t1 WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON 1);
DROP table t1,t2;
--echo #
--echo # Bug#751350: crash with pushed condition for outer references when
--echo # there should be none of such conditions
--echo #
CREATE TABLE t1 (a int, b int) ;
INSERT INTO t1 VALUES (0,0),(0,0);
EXPLAIN
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
SELECT b FROM t1
WHERE ('0') IN ( SELECT a FROM t1 GROUP BY a )
GROUP BY b;
DROP TABLE t1;
......@@ -7192,7 +7192,8 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
COND *outer_ref_cond= make_cond_for_table(cond,
OUTER_REF_TABLE_BIT,
(table_map) 0, FALSE, FALSE);
OUTER_REF_TABLE_BIT,
FALSE, FALSE);
if (outer_ref_cond)
{
add_cond_and_fix(&outer_ref_cond, join->outer_ref_cond);
......
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