revision-id: af46c25760bdc698cf219258f6c42316ed01b924 (mariadb-10.3.6-61-gaf46c25760b) parent(s): b1ae4e7e154b9b1ffb87918a8646173e1f8063fe author: Galina Shalygina committer: Galina Shalygina timestamp: 2018-08-01 14:42:47 +0300 message: MDEV-16727: Server crashes in Item_equal_iterator<List_iterator_fast, Item>::get_curr_field() The bug appeares because of the lamely saved list of multiple equalities. To fix it and_new_conditions_to_optimized_cond() was changed. --- mysql-test/main/in_subq_cond_pushdown.result | 24 +++++++++++++++++++++++ mysql-test/main/in_subq_cond_pushdown.test | 29 ++++++++++++++++++++++++++++ sql/opt_subselect.cc | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result index 4ad4180ff52..c9319a5fb86 100644 --- a/mysql-test/main/in_subq_cond_pushdown.result +++ b/mysql-test/main/in_subq_cond_pushdown.result @@ -3831,3 +3831,27 @@ WHERE (t1.a!=1) a 2 DROP TABLE t1; +# +# MDEV-16727: failure assertion caused by the lamely saved list +# of multiple equalities +# +CREATE TABLE t1 (a varchar(1)); +INSERT INTO `t1` VALUES ('x'), ('y'), ('z'); +CREATE TABLE t2 (b varchar(1)); +INSERT INTO t2 VALUES ('x'); +CREATE TABLE t3 (c varchar(1)); +INSERT INTO t3 VALUES ('y'); +CREATE TABLE t4 (d varchar(1)); +INSERT INTO t4 VALUES ('x'), ('z'); +SELECT * FROM t1 +JOIN t2 ON (t1.a=t2.b) +LEFT JOIN t3 ON (t1.a=t3.c) +WHERE (t1.a) IN +( +SELECT t4.d +FROM t4 +ORDER BY t4.d +); +a b c +x x NULL +DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test index 8f911ea2f19..3c673fb128b 100644 --- a/mysql-test/main/in_subq_cond_pushdown.test +++ b/mysql-test/main/in_subq_cond_pushdown.test @@ -792,3 +792,32 @@ WHERE tbl.a IN ); DROP TABLE t1; + +--echo # +--echo # MDEV-16727: failure assertion caused by the lamely saved list +--echo # of multiple equalities +--echo # + +CREATE TABLE t1 (a varchar(1)); +INSERT INTO `t1` VALUES ('x'), ('y'), ('z'); + +CREATE TABLE t2 (b varchar(1)); +INSERT INTO t2 VALUES ('x'); + +CREATE TABLE t3 (c varchar(1)); +INSERT INTO t3 VALUES ('y'); + +CREATE TABLE t4 (d varchar(1)); +INSERT INTO t4 VALUES ('x'), ('z'); + +SELECT * FROM t1 +JOIN t2 ON (t1.a=t2.b) +LEFT JOIN t3 ON (t1.a=t3.c) +WHERE (t1.a) IN +( + SELECT t4.d + FROM t4 + ORDER BY t4.d +); + +DROP TABLE t1,t2,t3,t4; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 1b3e2973133..06358b3cc20 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5624,7 +5624,7 @@ Item *and_new_conditions_to_optimized_cond(THD *thd, Item *cond, if (equality->fix_fields(thd, NULL)) return NULL; } - *cond_eq= &new_cond_equal; + (*cond_eq)->copy(new_cond_equal); } new_conds_list.append((List<Item> *)&new_cond_equal.current_level); }