diff options
author | Igor Babaev <igor@askmonty.org> | 2017-10-13 07:24:35 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2017-10-13 07:24:54 -0700 |
commit | 2bab29ebba7a641d43a98737fd1c160971357cd4 (patch) | |
tree | 0f6c87a6b706e4e18847418341681bf52605c699 /mysql-test | |
parent | 8be76a6a907ab858b4fdb5d525548aedfdb4ddf3 (diff) | |
download | mariadb-git-2bab29ebba7a641d43a98737fd1c160971357cd4.tar.gz |
Fixed the bug mdev-13135.
For each SELECT the list sj_nests is built by the
function simplify_joins() when scanning different
join nests. This function may be called several
times for the same join nest. That's why before
adding a new member to sj_nests it is necessary
to check if it's already in the list.
The code of simplify_joins() lacked this check and
as a result it could cause memory overwright for
some queries.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/subselect_mat_cost_bugs.result | 17 | ||||
-rw-r--r-- | mysql-test/t/subselect_mat_cost_bugs.test | 19 |
2 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/r/subselect_mat_cost_bugs.result b/mysql-test/r/subselect_mat_cost_bugs.result index 57b0526c6a3..df6b543bab8 100644 --- a/mysql-test/r/subselect_mat_cost_bugs.result +++ b/mysql-test/r/subselect_mat_cost_bugs.result @@ -502,3 +502,20 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index idx idx 5 NULL 5 Using where; Using index 2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away drop table t1; +# +# MDEV-13135: subquery with ON expression subject to +# semi-join optimizations +# +CREATE TABLE t1 (a INT); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a AS v_a FROM t1; +INSERT INTO t1 VALUES (1),(3); +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (3),(4); +SELECT * FROM t1 WHERE a NOT IN ( +SELECT b FROM t2 INNER JOIN v1 ON (b IN ( SELECT a FROM t1 )) +WHERE v_a = b +); +a +1 +DROP VIEW v1; +DROP TABLE t1,t2; diff --git a/mysql-test/t/subselect_mat_cost_bugs.test b/mysql-test/t/subselect_mat_cost_bugs.test index 35f2b9588fe..67af6e3a54a 100644 --- a/mysql-test/t/subselect_mat_cost_bugs.test +++ b/mysql-test/t/subselect_mat_cost_bugs.test @@ -522,4 +522,23 @@ select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5; drop table t1; +--echo # +--echo # MDEV-13135: subquery with ON expression subject to +--echo # semi-join optimizations +--echo # + +CREATE TABLE t1 (a INT); +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a AS v_a FROM t1; +INSERT INTO t1 VALUES (1),(3); + +CREATE TABLE t2 (b INT, KEY(b)); +INSERT INTO t2 VALUES (3),(4); + +SELECT * FROM t1 WHERE a NOT IN ( + SELECT b FROM t2 INNER JOIN v1 ON (b IN ( SELECT a FROM t1 )) + WHERE v_a = b +); + +DROP VIEW v1; +DROP TABLE t1,t2; |