diff options
author | Galina Shalygina <galina.shalygina@mariadb.com> | 2018-07-29 14:40:58 +0200 |
---|---|---|
committer | Galina Shalygina <galina.shalygina@mariadb.com> | 2018-07-29 14:40:58 +0200 |
commit | aee3d162d236412bd1b8146f62dca299ccd71017 (patch) | |
tree | f7c0fa398a665512ee89121a7acb2753f05fe30c | |
parent | 2a3d3e052f63cca4548c5bf8ef48040ecc39c5cf (diff) | |
download | mariadb-git-aee3d162d236412bd1b8146f62dca299ccd71017.tar.gz |
MDEV-16730: Server crashes in Bitmap<64u>::merge
The problem appears because of the pushdown of a non-pushable condition 'cond'
into the materialized derived table/view. To prevent pushdown a map of
tables that are used in 'cond' should be updated. This call is missing
because of the MDEV-12387 changes. The call is added in the
setup_jtbm_semi_joins() method.
-rw-r--r-- | mysql-test/main/in_subq_cond_pushdown.result | 17 | ||||
-rw-r--r-- | mysql-test/main/in_subq_cond_pushdown.test | 19 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 1 |
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index 06b7de7a5ac..4ad4180ff52 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -3814,3 +3814,20 @@ FROM t2 WHERE t2.b IN (SELECT MIN(t1.a) from t1); b DROP TABLE t1, t2; +# +# MDEV-16730: server fault caused by pushdown into the derived table +# condition that joins IN subquery and parent select +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); +SELECT * +FROM (SELECT DISTINCT * FROM t1) AS tbl +WHERE tbl.a IN +( +SELECT COUNT(t1.a) +FROM t1 +WHERE (t1.a!=1) +); +a +2 +DROP TABLE t1; diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test index fe317c3bf94..8f911ea2f19 100644 --- a/mysql-test/main/in_subq_cond_pushdown.test +++ b/mysql-test/main/in_subq_cond_pushdown.test @@ -773,3 +773,22 @@ FROM t2 WHERE t2.b IN (SELECT MIN(t1.a) from t1); DROP TABLE t1, t2; + +--echo # +--echo # MDEV-16730: server fault caused by pushdown into the derived table +--echo # condition that joins IN subquery and parent select +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3); + +SELECT * +FROM (SELECT DISTINCT * FROM t1) AS tbl +WHERE tbl.a IN +( + SELECT COUNT(t1.a) + FROM t1 + WHERE (t1.a!=1) +); + +DROP TABLE t1; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index de8cf1e54a1..1b3e2973133 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5924,6 +5924,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List<TABLE_LIST> *join_list, Item *item; while ((item=li++)) { + item->update_used_tables(); if (eq_list.push_back(item, thd->mem_root)) DBUG_RETURN(TRUE); } |