Skip to content

Commit

Permalink
Added the test case from for mdev-14777: Crash in MariaDB 10.2.12 on …
Browse files Browse the repository at this point in the history
…query

using VIEW and WITH RECURSIVE.

The cause of this crash was the same as of the crash reported in mdev-14755.
  • Loading branch information
igorbabaev committed Jan 5, 2018
1 parent 5783453 commit 15b1840
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mysql-test/r/cte_recursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -2944,3 +2944,31 @@ limit 1
);
ERROR HY000: Unacceptable mutual recursion with anchored table 'cte_1'
drop table t1;
#
# mdev-14777: crash caused by the same as in mdev-14755
#
CREATE TABLE t1 (i1 int NOT NULL, i2 int);
CREATE TABLE t2 (d1 int NOT NULL PRIMARY KEY);
CREATE TABLE t3 (i int );
insert into t1 select seq,seq from seq_1_to_100000;
insert into t2 select seq from seq_1000_to_100000;
insert into t3 select seq from seq_1_to_1000;
SELECT *
FROM
(
SELECT *
FROM
(
WITH RECURSIVE rt AS
(
SELECT i2 P, i1 C FROM t1 WHERE i1 IN (SELECT d1 FROM t2)
UNION
SELECT t1.i2 P, rt.C C FROM t1, rt
)
SELECT C,P
FROM ( SELECT P,C FROM rt WHERE NOT EXISTS (SELECT 1 FROM t1) ) Y
) X
WHERE 1 = 1
) K, t3;
C P i
drop table t1,t2,t3;
34 changes: 34 additions & 0 deletions mysql-test/t/cte_recursive.test
Original file line number Diff line number Diff line change
Expand Up @@ -1998,3 +1998,37 @@ set @var=
);

drop table t1;

--echo #
--echo # mdev-14777: crash caused by the same as in mdev-14755
--echo #

--source include/have_sequence.inc

CREATE TABLE t1 (i1 int NOT NULL, i2 int);
CREATE TABLE t2 (d1 int NOT NULL PRIMARY KEY);
CREATE TABLE t3 (i int );

insert into t1 select seq,seq from seq_1_to_100000;
insert into t2 select seq from seq_1000_to_100000;
insert into t3 select seq from seq_1_to_1000;

SELECT *
FROM
(
SELECT *
FROM
(
WITH RECURSIVE rt AS
(
SELECT i2 P, i1 C FROM t1 WHERE i1 IN (SELECT d1 FROM t2)
UNION
SELECT t1.i2 P, rt.C C FROM t1, rt
)
SELECT C,P
FROM ( SELECT P,C FROM rt WHERE NOT EXISTS (SELECT 1 FROM t1) ) Y
) X
WHERE 1 = 1
) K, t3;

drop table t1,t2,t3;

0 comments on commit 15b1840

Please sign in to comment.