Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
e5daa094
Commit
e5daa094
authored
Jun 02, 2014
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
5.3 merge
parents
759fa196
a1975dd2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
462 additions
and
11 deletions
+462
-11
mysql-test/r/view.result
mysql-test/r/view.result
+218
-2
mysql-test/t/view.test
mysql-test/t/view.test
+227
-2
sql/sql_derived.cc
sql/sql_derived.cc
+11
-6
sql/table.cc
sql/table.cc
+5
-0
sql/table.h
sql/table.h
+1
-1
No files found.
mysql-test/r/view.result
View file @
e5daa094
drop table if exists t1,t2,t3,t4,t9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop table if exists t1,t2,t3,t4,t
5,t6,t
9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,
t3,t4,t5,t6,t9,
`t1a``b`,v1,v2,v3,v4,v5,v6;
drop database if exists mysqltest;
drop database if exists mysqltest;
use test;
use test;
SET @save_optimizer_switch=@@optimizer_switch;
SET @save_optimizer_switch=@@optimizer_switch;
...
@@ -4116,6 +4116,114 @@ a
...
@@ -4116,6 +4116,114 @@ a
20
20
DROP VIEW v1,v2,v3;
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized
# with MERGE view)
#
CREATE TABLE t1 (a1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (b1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t3 (c1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t4 (d1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t5 (e1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t6 (f1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE OR REPLACE view v1 AS
SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
;
SELECT 1
FROM (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t1)
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t2) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t3) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t4) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t5) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t6) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t7) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t8) ON 1=1
;
1
SELECT 1
FROM (v1 t1)
LEFT OUTER JOIN (v1 t2) ON 1=1
LEFT OUTER JOIN (v1 t3) ON 1=1
LEFT OUTER JOIN (v1 t4) ON 1=1
LEFT OUTER JOIN (v1 t5) ON 1=1
LEFT OUTER JOIN (v1 t6) ON 1=1
LEFT OUTER JOIN (v1 t7) ON 1=1
LEFT OUTER JOIN (v1 t8) ON 1=1
;
1
drop view v1;
drop table t1,t2,t3,t4,t5,t6;
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# -- End of 5.2 tests.
# -- End of 5.2 tests.
# -----------------------------------------------------------------
# -----------------------------------------------------------------
...
@@ -5054,6 +5162,114 @@ execute stmt1;
...
@@ -5054,6 +5162,114 @@ execute stmt1;
deallocate prepare stmt1;
deallocate prepare stmt1;
drop view v1,v2;
drop view v1,v2;
drop table t1,t2;
drop table t1,t2;
#
# MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized
# with MERGE view)
#
CREATE TABLE t1 (a1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t2 (b1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t3 (c1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t4 (d1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t5 (e1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE t6 (f1 INT(11) NOT NULL DEFAULT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE OR REPLACE view v1 AS
SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
;
SELECT 1
FROM (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t1)
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t2) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t3) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t4) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t5) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t6) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t7) ON 1=1
LEFT OUTER JOIN (( SELECT 1
FROM t1 a_alias_1
LEFT JOIN (t2 b_alias_1 JOIN t1 a_alias_2) ON b_alias_1.b1 = a_alias_1.a1 AND a_alias_2.a1 = a_alias_1.a1
LEFT JOIN t3 c_alias_1 ON c_alias_1.c1 = a_alias_1.a1
LEFT JOIN t4 d_alias_1 ON d_alias_1.d1 = a_alias_1.a1
LEFT JOIN t3 c_alias_2 ON c_alias_2.c1 = a_alias_1.a1
LEFT JOIN t5 e_alias_1 ON e_alias_1.e1 = a_alias_1.a1
LEFT JOIN t6 f_alias_1 ON f_alias_1.f1 = a_alias_1.a1
) t8) ON 1=1
;
1
SELECT 1
FROM (v1 t1)
LEFT OUTER JOIN (v1 t2) ON 1=1
LEFT OUTER JOIN (v1 t3) ON 1=1
LEFT OUTER JOIN (v1 t4) ON 1=1
LEFT OUTER JOIN (v1 t5) ON 1=1
LEFT OUTER JOIN (v1 t6) ON 1=1
LEFT OUTER JOIN (v1 t7) ON 1=1
LEFT OUTER JOIN (v1 t8) ON 1=1
;
1
drop view v1;
drop table t1,t2,t3,t4,t5,t6;
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# -- End of 5.3 tests.
# -- End of 5.3 tests.
# -----------------------------------------------------------------
# -----------------------------------------------------------------
...
...
mysql-test/t/view.test
View file @
e5daa094
--
disable_warnings
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t9
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t
5
,
t6
,
t
9
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
view
if
exists
t1
,
t2
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
view
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t9
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
database
if
exists
mysqltest
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
--
enable_warnings
use
test
;
use
test
;
...
@@ -4083,6 +4083,118 @@ select * from t2;
...
@@ -4083,6 +4083,118 @@ select * from t2;
DROP
VIEW
v1
,
v2
,
v3
;
DROP
VIEW
v1
,
v2
,
v3
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized
--
echo
# with MERGE view)
--
echo
#
CREATE
TABLE
t1
(
a1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t2
(
b1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t3
(
c1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t4
(
d1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t5
(
e1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t6
(
f1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
OR
REPLACE
view
v1
AS
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
;
SELECT
1
FROM
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t1
)
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t2
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t3
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t4
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t5
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t6
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t7
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t8
)
ON
1
=
1
;
SELECT
1
FROM
(
v1
t1
)
LEFT
OUTER
JOIN
(
v1
t2
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t3
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t4
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t5
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t6
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t7
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t8
)
ON
1
=
1
;
drop
view
v1
;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
--
echo
# -- End of 5.2 tests.
--
echo
# -- End of 5.2 tests.
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
...
@@ -4971,6 +5083,119 @@ execute stmt1;
...
@@ -4971,6 +5083,119 @@ execute stmt1;
deallocate
prepare
stmt1
;
deallocate
prepare
stmt1
;
drop
view
v1
,
v2
;
drop
view
v1
,
v2
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# MDEV-6251: SIGSEGV in query optimizer (in set_check_materialized
--
echo
# with MERGE view)
--
echo
#
CREATE
TABLE
t1
(
a1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t2
(
b1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t3
(
c1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t4
(
d1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t5
(
e1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
TABLE
t6
(
f1
INT
(
11
)
NOT
NULL
DEFAULT
NULL
AUTO_INCREMENT
PRIMARY
KEY
);
CREATE
OR
REPLACE
view
v1
AS
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
;
SELECT
1
FROM
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t1
)
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t2
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t3
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t4
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t5
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t6
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t7
)
ON
1
=
1
LEFT
OUTER
JOIN
((
SELECT
1
FROM
t1
a_alias_1
LEFT
JOIN
(
t2
b_alias_1
JOIN
t1
a_alias_2
)
ON
b_alias_1
.
b1
=
a_alias_1
.
a1
AND
a_alias_2
.
a1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_1
ON
c_alias_1
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t4
d_alias_1
ON
d_alias_1
.
d1
=
a_alias_1
.
a1
LEFT
JOIN
t3
c_alias_2
ON
c_alias_2
.
c1
=
a_alias_1
.
a1
LEFT
JOIN
t5
e_alias_1
ON
e_alias_1
.
e1
=
a_alias_1
.
a1
LEFT
JOIN
t6
f_alias_1
ON
f_alias_1
.
f1
=
a_alias_1
.
a1
)
t8
)
ON
1
=
1
;
SELECT
1
FROM
(
v1
t1
)
LEFT
OUTER
JOIN
(
v1
t2
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t3
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t4
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t5
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t6
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t7
)
ON
1
=
1
LEFT
OUTER
JOIN
(
v1
t8
)
ON
1
=
1
;
drop
view
v1
;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
--
echo
# -- End of 5.3 tests.
--
echo
# -- End of 5.3 tests.
--
echo
# -----------------------------------------------------------------
--
echo
# -----------------------------------------------------------------
...
...
sql/sql_derived.cc
View file @
e5daa094
...
@@ -392,17 +392,13 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
...
@@ -392,17 +392,13 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
if
(
parent_lex
->
get_free_table_map
(
&
map
,
&
tablenr
))
if
(
parent_lex
->
get_free_table_map
(
&
map
,
&
tablenr
))
{
{
/* There is no enough table bits, fall back to materialization. */
/* There is no enough table bits, fall back to materialization. */
derived
->
change_refs_to_fields
();
goto
unconditional_materialization
;
derived
->
set_materialized_derived
();
goto
exit_merge
;
}
}
if
(
dt_select
->
leaf_tables
.
elements
+
tablenr
>
MAX_TABLES
)
if
(
dt_select
->
leaf_tables
.
elements
+
tablenr
>
MAX_TABLES
)
{
{
/* There is no enough table bits, fall back to materialization. */
/* There is no enough table bits, fall back to materialization. */
derived
->
change_refs_to_fields
();
goto
unconditional_materialization
;
derived
->
set_materialized_derived
();
goto
exit_merge
;
}
}
if
(
dt_select
->
options
&
OPTION_SCHEMA_TABLE
)
if
(
dt_select
->
options
&
OPTION_SCHEMA_TABLE
)
...
@@ -473,6 +469,15 @@ exit_merge:
...
@@ -473,6 +469,15 @@ exit_merge:
if
(
arena
)
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
thd
->
restore_active_arena
(
arena
,
&
backup
);
DBUG_RETURN
(
res
);
DBUG_RETURN
(
res
);
unconditional_materialization:
derived
->
change_refs_to_fields
();
derived
->
set_materialized_derived
();
if
(
!
derived
->
table
||
!
derived
->
table
->
created
)
res
=
mysql_derived_create
(
thd
,
lex
,
derived
);
if
(
!
res
)
res
=
mysql_derived_fill
(
thd
,
lex
,
derived
);
goto
exit_merge
;
}
}
...
...
sql/table.cc
View file @
e5daa094
...
@@ -4975,6 +4975,10 @@ void TABLE_LIST::set_check_merged()
...
@@ -4975,6 +4975,10 @@ void TABLE_LIST::set_check_merged()
void
TABLE_LIST
::
set_check_materialized
()
void
TABLE_LIST
::
set_check_materialized
()
{
{
DBUG_ENTER
(
"TABLE_LIST::set_check_materialized"
);
SELECT_LEX_UNIT
*
derived
=
this
->
derived
;
if
(
view
)
derived
=
&
view
->
unit
;
DBUG_ASSERT
(
derived
);
DBUG_ASSERT
(
derived
);
if
(
!
derived
->
first_select
()
->
exclude_from_table_unique_test
)
if
(
!
derived
->
first_select
()
->
exclude_from_table_unique_test
)
derived
->
set_unique_exclude
();
derived
->
set_unique_exclude
();
...
@@ -4987,6 +4991,7 @@ void TABLE_LIST::set_check_materialized()
...
@@ -4987,6 +4991,7 @@ void TABLE_LIST::set_check_materialized()
derived
->
first_select
()
->
first_inner_unit
()
->
first_select
()
->
derived
->
first_select
()
->
first_inner_unit
()
->
first_select
()
->
exclude_from_table_unique_test
);
exclude_from_table_unique_test
);
}
}
DBUG_VOID_RETURN
;
}
}
TABLE
*
TABLE_LIST
::
get_real_join_table
()
TABLE
*
TABLE_LIST
::
get_real_join_table
()
...
...
sql/table.h
View file @
e5daa094
...
@@ -2096,7 +2096,7 @@ struct TABLE_LIST
...
@@ -2096,7 +2096,7 @@ struct TABLE_LIST
void
set_materialized_derived
()
void
set_materialized_derived
()
{
{
DBUG_ENTER
(
"set_materialized_derived"
);
DBUG_ENTER
(
"set_materialized_derived"
);
derived_type
=
((
derived_type
&
DTYPE_MASK
)
|
derived_type
=
((
derived_type
&
(
derived
?
DTYPE_MASK
:
DTYPE_VIEW
)
)
|
DTYPE_TABLE
|
DTYPE_MATERIALIZE
);
DTYPE_TABLE
|
DTYPE_MATERIALIZE
);
set_check_materialized
();
set_check_materialized
();
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment