Commit 3a9ee22b authored by Igor Babaev's avatar Igor Babaev

Fixed the bug mdev-13734.

If the method SELECT_LEX::mark_const_derived() is called for a select
that is used in the specification of a materialized derived table / view D
then method should not set the flag fill_me for D on when
the flag JOIN::with_two_phase_optimization is set on for this select.
parent 61074d04
......@@ -10165,3 +10165,17 @@ WHERE d IN ( SELECT * FROM v1 ) AND c LIKE 'z%' OR c IS NULL;
c d
DROP VIEW v1;
DROP TABLE t1,t2,t3;
#
# MDEV-13734: Optimization for equi-joins of grouping derived tables
# (Splitting derived tables / views with GROUP BY) :
# derived table / view is empty
#
CREATE TABLE t1 (a int, b int, INDEX(a)) ENGINE=MyISAM;
CREATE TABLE t2 (c int) ENGINE=MyISAM;
CREATE VIEW v1 AS SELECT a, b FROM t1 STRAIGHT_JOIN t2;
CREATE VIEW v2 AS SELECT a, max(b) as bmax FROM v1 GROUP BY a;
CREATE VIEW v3 AS SELECT v2.* FROM t1 JOIN v2 ON t1.b = v2.bmax ;
SELECT * FROM v3 JOIN t1 ON (bmax = b);
a bmax a b
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
......@@ -1816,3 +1816,21 @@ SELECT * FROM t3
DROP VIEW v1;
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-13734: Optimization for equi-joins of grouping derived tables
--echo # (Splitting derived tables / views with GROUP BY) :
--echo # derived table / view is empty
--echo #
CREATE TABLE t1 (a int, b int, INDEX(a)) ENGINE=MyISAM;
CREATE TABLE t2 (c int) ENGINE=MyISAM;
CREATE VIEW v1 AS SELECT a, b FROM t1 STRAIGHT_JOIN t2;
CREATE VIEW v2 AS SELECT a, max(b) as bmax FROM v1 GROUP BY a;
CREATE VIEW v3 AS SELECT v2.* FROM t1 JOIN v2 ON t1.b = v2.bmax ;
SELECT * FROM v3 JOIN t1 ON (bmax = b);
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
......@@ -4608,7 +4608,8 @@ void SELECT_LEX::mark_const_derived(bool empty)
{
if (!empty)
increase_derived_records(1);
if (!master_unit()->is_unit_op() && !derived->is_merged_derived())
if (!master_unit()->is_unit_op() && !derived->is_merged_derived() &&
!(join && join->with_two_phase_optimization))
derived->fill_me= TRUE;
}
}
......
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