Commit 05314ed0 authored by Igor Babaev's avatar Igor Babaev

MDEV-31305 Crash caused by query with aggregation over materialized derived

This bug was fixed by the patch for bug MDEV-30706.
Only a test case is added in this commit.
parent f4ee7c11
......@@ -4217,4 +4217,38 @@ a
drop table t1, t2;
drop view v1;
drop procedure aproc;
#
# MDEV-31305: Aggregation over materialized derived table
#
CREATE VIEW v AS
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3;
SELECT v.*, SUM(p) from v;
dim1 dim2 dim3 p SUM(p)
100 10 1 2 371
SELECT d.*, SUM(p)
FROM (
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3
) d;
dim1 dim2 dim3 p SUM(p)
100 10 1 2 371
WITH demo AS
(
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3
)
SELECT d.*, SUM(p) FROM demo d;
dim1 dim2 dim3 p SUM(p)
100 10 1 2 371
DROP VIEW v;
# End of 10.4 tests
......@@ -2795,4 +2795,40 @@ drop table t1, t2;
drop view v1;
drop procedure aproc;
--echo #
--echo # MDEV-31305: Aggregation over materialized derived table
--echo #
--source include/have_sequence.inc
CREATE VIEW v AS
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3;
SELECT v.*, SUM(p) from v;
SELECT d.*, SUM(p)
FROM (
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3
) d;
WITH demo AS
(
SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
FLOOR(RAND(13) * 5) AS p
FROM seq_100_to_105 seq1
JOIN seq_10_to_15 seq2
JOIN seq_1_to_5 seq3
)
SELECT d.*, SUM(p) FROM demo d;
DROP VIEW v;
--echo # End of 10.4 tests
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