MDEV-16104 Server crash in JOIN::fix_all_splittings_in_plan

upon select with view and subqueries

This bug occurred when a splittable materialized derived/view
were used inside another splittable materialized derived/view.
The bug happened because the function JOIN::fix_all_splittings_in_plan()
was called at the very beginning of the optimization phase 2 at
the moment when the plan structure of the embedding derived/view
were not valid. The proper position for this call is the very
end of the optimization phase 1.
This commit is contained in:
Igor Babaev 2018-05-08 23:32:11 -07:00
commit fc0f5adb7f
3 changed files with 68 additions and 3 deletions

View file

@ -2690,3 +2690,26 @@ eval $q;
eval explain $q;
drop table t1;
--echo #
--echo # MDEV-16104: embedded splittable materialized derived/views
--echo #
CREATE TABLE t1 (f int PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1
VALUES (3), (7), (1), (4), (8), (5), (9);
CREATE ALGORITHM=MERGE VIEW v1 AS
SELECT a2.*
FROM
( SELECT f, COUNT(*) as c FROM t1 GROUP BY f ) AS a1
JOIN
t1 AS a2
USING (f);
EXPLAIN EXTENDED
SELECT * FROM ( SELECT STRAIGHT_JOIN f, COUNT(*) as c FROM v1 GROUP BY f ) AS s;
SELECT * FROM ( SELECT STRAIGHT_JOIN f, COUNT(*) as c FROM v1 GROUP BY f ) AS s;
DROP VIEW v1;
DROP TABLE t1;