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.
This commit is contained in:
Galina Shalygina 2018-08-01 14:42:47 +03:00
parent b1ae4e7e15
commit af46c25760
3 changed files with 54 additions and 1 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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);
}